20-11-23
This commit is contained in:
@@ -7,10 +7,12 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
public class EnvelopeController : BaseController
|
||||
{
|
||||
private readonly EnvelopeService envelopeService;
|
||||
private readonly EmailService emailService;
|
||||
|
||||
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
|
||||
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope, EmailService email) : base(database, logging)
|
||||
{
|
||||
envelopeService = envelope;
|
||||
emailService = email;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@@ -58,6 +60,10 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
Status = Common.Constants.DocumentStatus.Signed
|
||||
});
|
||||
|
||||
envelopeService.InsertHistoryEntrySigned(response);
|
||||
|
||||
SendSignedEmail(response);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -65,5 +71,18 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
return ErrorResponse(e);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SendSignedEmail(EnvelopeResponse response)
|
||||
{
|
||||
EmailTemplate template = new();
|
||||
EmailData emailData = new(response.Envelope, response.Receiver)
|
||||
{
|
||||
SignatureLink = "",
|
||||
};
|
||||
|
||||
template.FillDocumentSignedEmailBody(emailData);
|
||||
|
||||
return emailService.SendEmail(emailData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
{
|
||||
public class ActionObject
|
||||
{
|
||||
public string? ActionType { get; set; }
|
||||
public int ActionType { get; set; }
|
||||
}
|
||||
|
||||
public class HistoryController : BaseController
|
||||
@@ -25,18 +25,12 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Info("EnvelopeController/Get");
|
||||
logger.Info("HistoryController/Post");
|
||||
|
||||
// Validate Envelope Key and load envelope
|
||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
|
||||
|
||||
string actionTypeString = action.ActionType;
|
||||
|
||||
if (!Enum.TryParse<EnvelopeHistoryActionType>(actionTypeString, out var actionType))
|
||||
{
|
||||
return BadRequest();
|
||||
};
|
||||
EnvelopeHistoryActionType actionType = (EnvelopeHistoryActionType)action.ActionType;
|
||||
|
||||
envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user