IsRejected und ReadRejectedAsync Methoden zu EnvelopeHistoryService hinzugefügt.
This commit is contained in:
parent
047c4d09e8
commit
0818b8d606
@ -15,6 +15,8 @@ namespace EnvelopeGenerator.Application.Contracts
|
|||||||
|
|
||||||
Task<bool> IsSigned(int envelopeId, string userReference);
|
Task<bool> IsSigned(int envelopeId, string userReference);
|
||||||
|
|
||||||
|
Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null);
|
||||||
|
|
||||||
Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status);
|
Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,6 +35,27 @@ namespace EnvelopeGenerator.Application.Services
|
|||||||
userReference: userReference,
|
userReference: userReference,
|
||||||
status: (int) EnvelopeStatus.DocumentSigned) > 0;
|
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>> ReadRejectedAsync(int envelopeId, string? userReference = null) => _mapper.MapOrThrow<IEnumerable<EnvelopeHistoryDto>>(
|
||||||
|
await _repository.ReadAsync(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference: userReference,
|
||||||
|
status: (int)EnvelopeStatus.DocumentRejected));
|
||||||
|
|
||||||
public async Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status) =>
|
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))
|
await CreateAsync(new (EnvelopeId: envelopeId, UserReference: userReference, Status: (int)status, ActionDate: DateTime.Now))
|
||||||
.ThenAsync(
|
.ThenAsync(
|
||||||
|
|||||||
@ -6,5 +6,7 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
|
|||||||
public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, long>
|
public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, long>
|
||||||
{
|
{
|
||||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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)
|
||||||
{
|
{
|
||||||
var query = _dbSet.AsQueryable();
|
var query = _dbSet.AsQueryable();
|
||||||
|
|
||||||
if (envelopeId is not null)
|
if (envelopeId is not null)
|
||||||
query = query.Where(eh => eh.EnvelopeId == envelopeId);
|
query = query.Where(eh => eh.EnvelopeId == envelopeId);
|
||||||
|
|
||||||
@ -25,7 +25,17 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
|||||||
if (status is not null)
|
if (status is not null)
|
||||||
query = query.Where(eh => eh.Status == status);
|
query = query.Where(eh => eh.Status == status);
|
||||||
|
|
||||||
return await query.CountAsync();
|
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) => await By(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference: userReference,
|
||||||
|
status: status).ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user