29-11-2023

This commit is contained in:
Jonathan Jenne
2023-11-29 16:15:48 +01:00
parent c964b97e55
commit 1b88a6cff7
23 changed files with 342 additions and 257 deletions

View File

@@ -9,10 +9,10 @@ namespace EnvelopeGenerator.Web.Controllers
private readonly EnvelopeService envelopeService;
private readonly EmailService emailService;
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope, EmailService email) : base(database, logging)
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
{
envelopeService = envelope;
emailService = email;
emailService = new(state);
}
[HttpGet]
@@ -62,7 +62,7 @@ namespace EnvelopeGenerator.Web.Controllers
envelopeService.InsertHistoryEntrySigned(response);
SendSignedEmail(response);
emailService.SendSignedEmail(response.Receiver.Id, response.Envelope.Id);
return Ok();
}
@@ -71,18 +71,5 @@ 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);
}
}
}

View File

@@ -5,11 +5,6 @@ using static EnvelopeGenerator.Common.Constants;
namespace EnvelopeGenerator.Web.Controllers
{
public class ActionObject
{
public int ActionType { get; set; }
}
public class HistoryController : BaseController
{
private readonly EnvelopeService envelopeService;
@@ -21,7 +16,7 @@ namespace EnvelopeGenerator.Web.Controllers
[HttpPost]
[Route("api/history/{envelopeKey}")]
public IActionResult Get(string envelopeKey, [FromBody] ActionObject action)
public IActionResult Get(string envelopeKey)
{
try
{
@@ -30,12 +25,11 @@ namespace EnvelopeGenerator.Web.Controllers
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
EnvelopeHistoryActionType actionType = (EnvelopeHistoryActionType)action.ActionType;
envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry()
{
ActionDate = DateTime.Now,
ActionType = actionType,
Status = EnvelopeStatus.DocumentOpened,
EnvelopeId = response.Envelope.Id,
UserReference = response.Receiver.Email
});

View File

@@ -11,7 +11,6 @@ namespace EnvelopeGenerator.Web
// Add base services
builder.Services.AddSingleton<LoggingService>();
builder.Services.AddTransient<DatabaseService>();
builder.Services.AddTransient<EmailService>();
// Add higher order services
builder.Services.AddSingleton<EnvelopeService>();

View File

@@ -1,38 +0,0 @@
using EnvelopeGenerator.Common;
namespace EnvelopeGenerator.Web.Services
{
public class EmailService : BaseService
{
private ReceiverModel receiverModel;
private EnvelopeModel envelopeModel;
private HistoryModel historyModel;
private DocumentModel documentModel;
private DocumentStatusModel documentStatusModel;
private EmailModel emailModel;
public EmailService(IConfiguration Config, LoggingService Logging, DatabaseService database) : base(Config, Logging)
{
logger = Logging.LogConfig.GetLogger();
if (database.Models == null)
{
throw new ArgumentNullException("Models not loaded.");
}
receiverModel = database.Models.receiverModel;
envelopeModel = database.Models.envelopeModel;
historyModel = database.Models.historyModel;
documentModel = database.Models.documentModel;
documentStatusModel = database.Models.documentStatusModel;
emailModel = database.Models.emailModel;
}
public bool SendEmail(EmailData emailData)
{
return emailModel.Insert(emailData);
}
}
}

View File

@@ -111,7 +111,7 @@ namespace EnvelopeGenerator.Web.Services
return historyModel.Insert(new EnvelopeHistoryEntry()
{
ActionDate = DateTime.Now,
ActionType = EnvelopeHistoryActionType.Signed,
Status = EnvelopeStatus.DocumentSigned,
EnvelopeId = response.Envelope.Id,
UserReference = response.Receiver.Email
});

View File

@@ -90,7 +90,7 @@ class App {
)
const createdAnnotations = await this.Instance.create(annotations)
await this.Network.postHistory(this.envelopeKey, ActionType.Seen)
await this.Network.postHistory(this.envelopeKey)
} catch (e) {
console.error(e)
}

View File

@@ -32,20 +32,16 @@
})
}
postHistory(envelopeKey, actionType) {
postHistory(envelopeKey) {
const url = `/api/history/${envelopeKey}`
const data = {
actionType: actionType,
}
const options = {
credentials: 'include',
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
body: JSON.stringify(data),
body: JSON.stringify({}),
}
console.debug('PostHistory/Calling url: ' + url)