Remove Blazor
This commit is contained in:
62
EnvelopeGenerator.Web/Controllers/HistoryController.cs
Normal file
62
EnvelopeGenerator.Web/Controllers/HistoryController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user