Create new Web Project

This commit is contained in:
Jonathan Jenne
2023-11-08 08:59:25 +01:00
parent d0a4249eb7
commit 2e148de18e
765 changed files with 173 additions and 12962 deletions

View File

@@ -1,30 +0,0 @@
using DigitalData.Modules.Logging;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
using static EnvelopeGenerator.Web.Constants;
namespace EnvelopeGenerator.Web.Controllers
{
public class BaseController : Controller
{
internal DatabaseService database;
internal LogConfig logConfig;
internal Logger logger;
public BaseController(DatabaseService database, LoggingService logging)
{
this.database = database;
this.logConfig = logging.LogConfig;
this.logger = logging.LogConfig.GetLoggerFor(GetType().Name);
}
internal ObjectResult ErrorResponse(Exception e)
{
logger.Error(e);
return Problem(
statusCode: 500,
detail: e.Message,
type: ErrorType.ServerError.ToString());
}
}
}

View File

@@ -1,74 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
namespace EnvelopeGenerator.Web.Controllers
{
public class DocumentController : BaseController
{
private readonly EnvelopeService envelopeService;
public DocumentController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
{
envelopeService = envelope;
}
[HttpGet]
[Route("api/document/{envelopeKey}")]
public async Task<IActionResult> Get(string envelopeKey)
{
try
{
logger.Info("DocumentController/Get");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
// Load document info
var Request = ControllerContext.HttpContext.Request;
var document = envelopeService.GetDocument(Request, envelopeKey);
// Load the document from disk
var bytes = await envelopeService.GetDocumentContents(document);
// Return the document as bytes
return File(bytes, "application/octet-stream");
}
catch (Exception e)
{
return ErrorResponse(e);
}
}
[HttpPost]
[Route("api/document/{envelopeKey}")]
public async Task<IActionResult> Update(string envelopeKey)
{
try
{
logger.Info("DocumentController/Update");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
// Load Document info
var Request = ControllerContext.HttpContext.Request;
var document = envelopeService.GetDocument(Request, envelopeKey);
// Update the document with new data
await envelopeService.UpdateDocument(Request.Body, document.Filepath);
// Add history entry
envelopeService.InsertHistoryEntrySigned(response);
return Ok();
}
catch (Exception e)
{
return ErrorResponse(e);
}
}
}
}

View File

@@ -1,71 +0,0 @@
using DigitalData.Modules.Logging;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
using static EnvelopeGenerator.Web.Constants;
namespace EnvelopeGenerator.Web.Controllers
{
public class EnvelopeController : BaseController
{
private readonly EnvelopeService envelopeService;
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
{
envelopeService = envelope;
}
[HttpGet]
[Route("api/envelope/{envelopeKey}")]
public IActionResult Get(string envelopeKey)
{
try
{
logger.Info("EnvelopeController/Get");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
return Json(response);
}
catch (Exception e)
{
return ErrorResponse(e);
}
}
[HttpPost]
[Route("api/envelope/{envelopeKey}")]
public async Task<IActionResult> Update(string envelopeKey)
{
try
{
logger.Info("EnvelopeController/Update");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
var Request = ControllerContext.HttpContext.Request;
var document = envelopeService.GetDocument(Request, envelopeKey);
string annotationData = await envelopeService.EnsureValidAnnotationData(Request);
envelopeService.InsertDocumentStatus(new DocumentStatus()
{
EnvelopeId = response.Envelope.Id,
ReceiverId = response.Receiver.Id,
Value = annotationData,
Status = Common.Constants.DocumentStatus.Signed
});
return Ok();
}
catch (Exception e)
{
return ErrorResponse(e);
}
}
}
}