fix service, fix duplicate emails. fix tempalte

This commit is contained in:
Jonathan Jenne
2023-12-06 16:05:05 +01:00
parent 588b532d86
commit 327102d63a
3 changed files with 20 additions and 9 deletions

View File

@@ -23,6 +23,7 @@ namespace EnvelopeGenerator.Web.Services
receiverModel = database.Models.receiverModel;
envelopeModel = database.Models.envelopeModel;
documentStatusModel = database.Models.documentStatusModel;
}
public void EnsureValidEnvelopeKey(string envelopeKey)
@@ -45,30 +46,41 @@ namespace EnvelopeGenerator.Web.Services
public EnvelopeResponse LoadEnvelope(string pEnvelopeKey)
{
logger.Debug("Loading Envelope by Key [{0}]", pEnvelopeKey);
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
var envelopeUuid = result.Item1;
var receiverSignature = result.Item2;
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
Envelope? envelope = envelopeModel.GetByUuid(envelopeUuid);
Envelope? envelope = envelopeModel.GetByUuid(envelopeUuid);
if (envelope == null)
{
logger.Warn("Envelope not found");
throw new NullReferenceException("Envelope not found");
}
logger.Debug("Envelope loaded");
if (envelope.Receivers == null)
{
logger.Warn("Receivers for envelope not loaded");
throw new NullReferenceException("Receivers for envelope not loaded");
}
logger.Debug("Envelope receivers found: [{0}]", envelope.Receivers.Count);
EnvelopeReceiver? receiver = envelope.Receivers.Where(r => r.Id == receiverId).SingleOrDefault();
if (receiver == null)
{
logger.Warn("Receiver not found");
throw new NullReferenceException("Receiver not found");
}
logger.Debug("Loading documents for receiver [{0}]", receiver.Email);
envelope.Documents = FilterElementsByReceiver(envelope, receiverId);
return new()
@@ -105,6 +117,8 @@ namespace EnvelopeGenerator.Web.Services
await request.BodyReader.CopyToAsync(ms);
var bytes = ms.ToArray();
logger.Debug("Annotation data parsed, size: [{0}]", bytes.Length);
return Encoding.UTF8.GetString(bytes);
}
catch (Exception e)
@@ -158,6 +172,7 @@ namespace EnvelopeGenerator.Web.Services
public bool InsertDocumentStatus(Common.DocumentStatus documentStatus)
{
logger.Debug("Saving annotation data..");
return documentStatusModel.InsertOrUpdate(documentStatus);
}