Referenztyp hinzugefügt, um zu klassifizieren, für wen Geschichte geschrieben wird.

This commit is contained in:
Developer 02
2024-06-04 13:50:17 +02:00
parent 65618e5df9
commit 34b3c46720
10 changed files with 66 additions and 15 deletions

View File

@@ -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);

View 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>();
}
}

View File

@@ -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);
}

View File

@@ -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);