Refactor EnvelopeStatus usage and streamline code

- Added `EnvelopeGenerator.Domain.Constants` in multiple files, replacing `Domain.Constants.EnvelopeStatus` with `EnvelopeStatus` for improved readability.
- Modified `CreateEnvelopeCommandHandler.cs` to directly use `request.UserId`, eliminating unnecessary local variable assignment.
- Identified potential duplication in query logic within `ReceiverAlreadySignedQuery.cs`.
- Updated `IEnvelopeService`, `EnvelopeReceiverService`, and `EnvelopeService` to ensure consistent usage of the simplified `EnvelopeStatus`.
- Overall, these changes enhance code maintainability and clarity.
This commit is contained in:
2025-09-01 11:11:30 +02:00
parent ef7e694c9f
commit 48ce0d5f32
9 changed files with 20 additions and 21 deletions

View File

@@ -1,11 +1,10 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Model;
using EnvelopeGenerator.Domain;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Application.Extensions;
using MediatR;
using Microsoft.EntityFrameworkCore;
using EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
@@ -70,9 +69,9 @@ public class ReceiverAlreadySignedQueryHandler : IRequestHandler<ReceiverAlready
public async Task<bool> Handle(ReceiverAlreadySignedQuery request, CancellationToken cancel = default)
{
return await _repo.Read()
.Where(er => er.Envelope.Uuid == request.Envelope.Uuid)
.Where(er => er.Receiver.Signature == request.Receiver.Signature)
.Where(er => er.Envelope.History.Any(hist => hist.Status == EnvelopeStatus.DocumentSigned))
.Where(er => er.Envelope!.Uuid == request.Envelope.Uuid)
.Where(er => er.Receiver!.Signature == request.Receiver.Signature)
.Where(er => er.Envelope!.History.Any(hist => hist.Status == EnvelopeStatus.DocumentSigned))
.AnyAsync(cancel);
}
}