From 3ba7bfd15a8e5b2cdac12dde19bcec8373aba053 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 9 Sep 2025 19:01:20 +0200 Subject: [PATCH] refactor(EnvelopeHistoryDto): rename HostoryDto --- .../{EnvelopeHistoryCreateDto.cs => HistoryCreateDto.cs} | 2 +- .../{EnvelopeHistoryDto.cs => HistoryDto.cs} | 2 +- .../Common/Dto/MappingProfile.cs | 8 ++++---- .../Histories/Commands/CreateHistoryCommand.cs | 8 ++++---- .../Histories/Queries/ReadHistoryQuery.cs | 2 +- .../Histories/Queries/ReadHistoryQueryHandler.cs | 6 +++--- .../Interfaces/Services/IEnvelopeHistoryService.cs | 6 +++--- .../Services/EnvelopeHistoryService.cs | 8 ++++---- EnvelopeGenerator.Tests.Application/HistoryTests.cs | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) rename EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/{EnvelopeHistoryCreateDto.cs => HistoryCreateDto.cs} (96%) rename EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/{EnvelopeHistoryDto.cs => HistoryDto.cs} (98%) diff --git a/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/EnvelopeHistoryCreateDto.cs b/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/HistoryCreateDto.cs similarity index 96% rename from EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/EnvelopeHistoryCreateDto.cs rename to EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/HistoryCreateDto.cs index 98a8544d..fc58f98c 100644 --- a/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/EnvelopeHistoryCreateDto.cs +++ b/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/HistoryCreateDto.cs @@ -5,7 +5,7 @@ namespace EnvelopeGenerator.Application.Common.Dto.EnvelopeHistory; /// /// Data Transfer Object for creating a new envelope history record. /// -public class EnvelopeHistoryCreateDto +public class HistoryCreateDto { /// /// Gets or sets the identifier of the envelope. diff --git a/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs b/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/HistoryDto.cs similarity index 98% rename from EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs rename to EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/HistoryDto.cs index d2ba3dfc..2a22a4ea 100644 --- a/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs +++ b/EnvelopeGenerator.Application/Common/Dto/EnvelopeHistory/HistoryDto.cs @@ -7,7 +7,7 @@ namespace EnvelopeGenerator.Application.Common.Dto.EnvelopeHistory; /// /// Data Transfer Object representing the history of an envelope, including status, sender, receiver, and related metadata. /// -public record EnvelopeHistoryDto +public record HistoryDto { /// /// Unique identifier for the envelope history entry. diff --git a/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs b/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs index 82ca577a..7b0897e5 100644 --- a/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs +++ b/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs @@ -29,8 +29,8 @@ public class MappingProfile : Profile CreateMap(); CreateMap(); CreateMap(); - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap(); @@ -45,8 +45,8 @@ public class MappingProfile : Profile CreateMap(); CreateMap(); CreateMap(); - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap().ForMember(rcv => rcv.EnvelopeReceivers, rcvReadDto => rcvReadDto.Ignore()); diff --git a/EnvelopeGenerator.Application/Histories/Commands/CreateHistoryCommand.cs b/EnvelopeGenerator.Application/Histories/Commands/CreateHistoryCommand.cs index f1489248..6dc12c0e 100644 --- a/EnvelopeGenerator.Application/Histories/Commands/CreateHistoryCommand.cs +++ b/EnvelopeGenerator.Application/Histories/Commands/CreateHistoryCommand.cs @@ -14,7 +14,7 @@ namespace EnvelopeGenerator.Application.Histories.Commands; /// /// /// -public record CreateHistoryCommand : EnvelopeReceiverQueryBase, IRequest +public record CreateHistoryCommand : EnvelopeReceiverQueryBase, IRequest { /// /// @@ -50,7 +50,7 @@ public record CreateHistoryCommand : EnvelopeReceiverQueryBase, IRequest /// /// -public class CreateHistoryCommandHandler : IRequestHandler +public class CreateHistoryCommandHandler : IRequestHandler { private readonly IRepository _repo; @@ -77,7 +77,7 @@ public class CreateHistoryCommandHandler : IRequestHandler /// /// - public async Task Handle(CreateHistoryCommand request, CancellationToken cancel) + public async Task Handle(CreateHistoryCommand request, CancellationToken cancel) { if(request.UserReference is null) { @@ -103,6 +103,6 @@ public class CreateHistoryCommandHandler : IRequestHandler(hist); + return _mapper.Map(hist); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs index 9a68dd5c..585f41f9 100644 --- a/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs +++ b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs @@ -9,7 +9,7 @@ namespace EnvelopeGenerator.Application.Histories.Queries; /// /// Repräsentiert eine Abfrage für die Verlaufshistorie eines Umschlags. /// -public record ReadHistoryQuery : IRequest> +public record ReadHistoryQuery : IRequest> { /// /// Die eindeutige Kennung des Umschlags. diff --git a/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQueryHandler.cs b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQueryHandler.cs index 5919b00d..41709c3d 100644 --- a/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQueryHandler.cs +++ b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQueryHandler.cs @@ -11,7 +11,7 @@ namespace EnvelopeGenerator.Application.Histories.Queries; /// /// /// -public class ReadHistoryQueryHandler : IRequestHandler> +public class ReadHistoryQueryHandler : IRequestHandler> { private readonly IRepository _repo; @@ -35,13 +35,13 @@ public class ReadHistoryQueryHandler : IRequestHandler /// /// - public async Task> Handle(ReadHistoryQuery request, CancellationToken cancel = default) + public async Task> Handle(ReadHistoryQuery request, CancellationToken cancel = default) { var query = _repo.ReadOnly().Where(h => h.EnvelopeId == request.EnvelopeId); if (request.Status is not null) query = query.Where(h => h.Status == request.Status); var hists = await query.ToListAsync(cancel); - return _mapper.Map>(hists); + return _mapper.Map>(hists); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs index fb03958e..7f8a84c5 100644 --- a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs +++ b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs @@ -11,7 +11,7 @@ namespace EnvelopeGenerator.Application.Interfaces.Services; /// /// [Obsolete("Use MediatR")] -public interface IEnvelopeHistoryService : ICRUDService +public interface IEnvelopeHistoryService : ICRUDService { /// /// @@ -56,7 +56,7 @@ public interface IEnvelopeHistoryService : ICRUDService /// /// - Task> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false); + Task> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false); /// /// @@ -64,7 +64,7 @@ public interface IEnvelopeHistoryService : ICRUDService /// /// - Task> ReadRejectedAsync(int envelopeId, string? userReference = null); + Task> ReadRejectedAsync(int envelopeId, string? userReference = null); /// /// diff --git a/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs b/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs index 54e34a08..ac38b5b6 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs @@ -14,7 +14,7 @@ namespace EnvelopeGenerator.Application.Services; /// /// [Obsolete("Use MediatR")] -public class EnvelopeHistoryService : CRUDService, IEnvelopeHistoryService +public class EnvelopeHistoryService : CRUDService, IEnvelopeHistoryService { /// /// @@ -94,9 +94,9 @@ public class EnvelopeHistoryService : CRUDService /// /// - public async Task> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false) + public async Task> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false) { - var histDTOs = _mapper.Map>( + var histDTOs = _mapper.Map>( await _repository.ReadAsync( envelopeId: envelopeId, userReference: userReference, @@ -112,7 +112,7 @@ public class EnvelopeHistoryService : CRUDService /// /// - public async Task> ReadRejectedAsync(int envelopeId, string? userReference = null) => + public async Task> ReadRejectedAsync(int envelopeId, string? userReference = null) => await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: EnvelopeStatus.DocumentRejected, withReceiver:true); //TODO: use IQueryable in repository to incerease the performance diff --git a/EnvelopeGenerator.Tests.Application/HistoryTests.cs b/EnvelopeGenerator.Tests.Application/HistoryTests.cs index 68ecf8eb..ab00072a 100644 --- a/EnvelopeGenerator.Tests.Application/HistoryTests.cs +++ b/EnvelopeGenerator.Tests.Application/HistoryTests.cs @@ -96,7 +96,7 @@ public class HistoryTests : TestBase // Assert Assert.That(result, Has.Exactly(1).Items); - Assert.That(result, Has.All.Matches(r => r.Status == EnvelopeStatus.EnvelopeCompletelySigned)); + Assert.That(result, Has.All.Matches(r => r.Status == EnvelopeStatus.EnvelopeCompletelySigned)); } [Test]