Referenztyp hinzugefügt, um zu klassifizieren, für wen Geschichte geschrieben wird.
This commit is contained in:
@@ -15,7 +15,7 @@ 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>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null);
|
||||
|
||||
Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null);
|
||||
|
||||
|
||||
14
EnvelopeGenerator.Application/DIExtensions.cs
Normal file
14
EnvelopeGenerator.Application/DIExtensions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Application.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using static EnvelopeGenerator.Common.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application
|
||||
{
|
||||
public static class DIExtensions
|
||||
{
|
||||
public static IServiceCollection AddHistoryService(this IServiceCollection services, Func<EnvelopeStatus, ReferenceType>? classifier = null) => services
|
||||
.AddSingleton(classifier ?? EnvelopeHistoryService.DefaultClassifier)
|
||||
.AddScoped<IEnvelopeHistoryService, EnvelopeHistoryService>();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeHistory
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using static EnvelopeGenerator.Common.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeHistory
|
||||
{
|
||||
public record EnvelopeHistoryDto(
|
||||
long Id,
|
||||
@@ -7,6 +10,8 @@
|
||||
int Status,
|
||||
DateTime AddedWhen,
|
||||
DateTime? ActionDate,
|
||||
UserCreateDto? Sender,
|
||||
ReceiverDto? Receiver,
|
||||
ReferenceType ReferenceType,
|
||||
string? Comment = null);
|
||||
}
|
||||
@@ -50,11 +50,15 @@ namespace EnvelopeGenerator.Application.Services
|
||||
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>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null)
|
||||
{
|
||||
var histDTOs = _mapper.MapOrThrow<IEnumerable<EnvelopeHistoryDto>>(
|
||||
await _repository.ReadAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
status: status));
|
||||
return referenceType is null ? histDTOs : histDTOs.Where(h => h.ReferenceType == referenceType);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null) =>
|
||||
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: (int)EnvelopeStatus.DocumentRejected);
|
||||
|
||||
Reference in New Issue
Block a user