Compare commits

..

5 Commits

10 changed files with 77 additions and 5 deletions

View File

@@ -15,6 +15,10 @@ namespace EnvelopeGenerator.Application.Contracts
Task<bool> IsSigned(int envelopeId, string userReference);
Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null);
Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null);
Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status);
}
}

View File

@@ -4,5 +4,6 @@
int EnvelopeId,
string UserReference,
int Status,
DateTime? ActionDate);
DateTime? ActionDate,
string? Comment = null);
}

View File

@@ -6,5 +6,7 @@
string UserReference,
int Status,
DateTime AddedWhen,
DateTime? ActionDate);
DateTime? ActionDate,
ReceiverDto? Receiver,
string? Comment = null);
}

View File

@@ -35,6 +35,30 @@ namespace EnvelopeGenerator.Application.Services
userReference: userReference,
status: (int) EnvelopeStatus.DocumentSigned) > 0;
/// <summary>
/// Checks if the specified envelope has been rejected.
/// <para><b>Note:</b> <i>If any document within the envelope is rejected, the entire envelope will be considered rejected.</i></para>
/// </summary>
/// <param name="envelopeId">The ID of the envelope to check.</param>
/// <param name="userReference">Optional user reference associated with the envelope.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the envelope is rejected.</returns>
public async Task<bool> IsRejected(int envelopeId, string? userReference = null)
{
return await _repository.CountAsync(
envelopeId: envelopeId,
userReference: userReference,
status: (int)EnvelopeStatus.DocumentRejected) > 0;
}
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null) => _mapper.MapOrThrow<IEnumerable<EnvelopeHistoryDto>>(
await _repository.ReadAsync(
envelopeId: envelopeId,
userReference: userReference,
status: status));
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null) =>
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: (int)EnvelopeStatus.DocumentRejected);
public async Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status) =>
await CreateAsync(new (EnvelopeId: envelopeId, UserReference: userReference, Status: (int)status, ActionDate: DateTime.Now))
.ThenAsync(

View File

@@ -18,6 +18,7 @@
DocumentOpened = 2004
DocumentSigned = 2005
SignatureConfirmed = 2006
DocumentRejected = 2007
MessageInvitationSent = 3001 ' Wird von Trigger verwendet
MessageAccessCodeSent = 3002
MessageConfirmationSent = 3003

View File

@@ -30,5 +30,14 @@ namespace EnvelopeGenerator.Domain.Entities
[Column("ACTION_DATE", TypeName = "datetime")]
public DateTime? ActionDate { get; set; }
[Column("COMMENT", TypeName = "nvarchar(max)")]
public string? Comment { get; set; }
//[ForeignKey("UserReference")]
//public virtual DigitalData.UserManager.Domain.Entities.User? Sender { get; set; }
[ForeignKey("UserReference")]
public virtual Receiver? Receiver { get; set; }
}
}

View File

@@ -6,5 +6,7 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, long>
{
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withReceiver = true);
}
}

View File

@@ -48,6 +48,12 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
.WithMany(ed => ed.Elements)
.HasForeignKey(dre => dre.DocumentId);
modelBuilder.Entity<EnvelopeHistory>()
.HasOne(eh => eh.Receiver)
.WithMany()
.HasForeignKey(eh => eh.UserReference)
.HasPrincipalKey(e => e.EmailAddress);
// Configure entities to handle database triggers
modelBuilder.Entity<Envelope>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));
modelBuilder.Entity<EnvelopeHistory>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));

View File

@@ -12,10 +12,10 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
{
}
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null)
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, int? status = null, bool withReceiver = false)
{
var query = _dbSet.AsQueryable();
if (envelopeId is not null)
query = query.Where(eh => eh.EnvelopeId == envelopeId);
@@ -25,7 +25,21 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
if (status is not null)
query = query.Where(eh => eh.Status == status);
return await query.CountAsync();
if(withReceiver)
query = query.Include(eh => eh.Receiver);
return query;
}
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await By(
envelopeId: envelopeId,
userReference: userReference,
status: status).CountAsync();
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withReceiver = true) => await By(
envelopeId: envelopeId,
userReference: userReference,
status: status,
withReceiver: withReceiver).ToListAsync();
}
}

View File

@@ -24,5 +24,14 @@ namespace EnvelopeGenerator.Web.Controllers.Test
{
return Ok(await _service.AccessCodeAlreadyRequested(envelopeId, userReference));
}
[HttpGet]
public async Task<IActionResult> GetAsyncWith(int? envelopeId = null, string? userReference = null, int? status = null)
{
return Ok(await _service.ReadAsync(envelopeId: envelopeId, userReference: userReference, status: status));
}
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
}
}