Remove Blazor

This commit is contained in:
Jonathan Jenne
2023-11-08 14:52:14 +01:00
parent ba1d6acfa4
commit 2c936c2629
1614 changed files with 75165 additions and 14959 deletions

View File

@@ -0,0 +1,30 @@
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

@@ -0,0 +1,74 @@
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

@@ -0,0 +1,71 @@
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);
}
}
}
}

View File

@@ -0,0 +1,62 @@
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
using static EnvelopeGenerator.Common.Constants;
using System;
using static System.Collections.Specialized.BitVector32;
namespace EnvelopeGenerator.Web.Controllers
{
public class ActionObject
{
public string? ActionType { get; set; }
public string? ActionDescription { get; set; }
}
public class HistoryController : BaseController
{
private readonly EnvelopeService envelopeService;
public HistoryController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
{
envelopeService = envelope;
}
[HttpPost]
[Route("api/history/{envelopeKey}")]
public IActionResult Get(string envelopeKey, [FromBody] ActionObject action)
{
try
{
logger.Info("EnvelopeController/Get");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
string actionTypeString = action.ActionType;
string actionDescription = action.ActionDescription;
if (!Enum.TryParse<EnvelopeHistoryActionType>(actionTypeString, out var actionType))
{
return BadRequest();
};
envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry()
{
ActionDescription = actionDescription,
ActionDate = DateTime.Now,
ActionType = actionType,
EnvelopeId = response.Envelope.Id,
UserReference = response.Receiver.Email
});
return Ok();
}
catch (Exception e)
{
return ErrorResponse(e);
}
}
}
}

View File

@@ -0,0 +1,45 @@
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Models;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace EnvelopeGenerator.Web.Controllers
{
public class HomeController : Controller
{
private readonly EnvelopeService _envelopeService;
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger, EnvelopeService envelopeService)
{
_envelopeService = envelopeService;
_logger = logger;
}
[HttpGet]
[Route("/")]
public IActionResult Index()
{
var receiverId = 1;
List<Envelope> envelopes = _envelopeService.LoadEnvelopes(receiverId);
return View(envelopes);
}
[HttpGet]
[Route("/EnvelopeKey/{EnvelopeReceiverId}")]
public IActionResult Show()
{
ViewData["EnvelopeKey"] = HttpContext.Request.RouteValues["EnvelopeReceiverId"];
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}