diff --git a/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs b/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs index 28a24b80..85874a56 100644 --- a/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs +++ b/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs @@ -1,9 +1,8 @@ using DigitalData.Core.Abstraction.Application.Repository; -using DigitalData.Core.Exceptions; using EnvelopeGenerator.Domain.Entities; using MediatR; using Microsoft.EntityFrameworkCore; -using System.Linq.Expressions; +using EnvelopeGenerator.Application.Extensions; namespace EnvelopeGenerator.Application.DocStatus.Commands; @@ -60,30 +59,13 @@ public class SaveDocStatusCommandHandler : IRequestHandler public async Task Handle(SaveDocStatusCommand request, CancellationToken cancel) { - // envelope filter - Expression>? eExp = - request.Envelope.Id is not null - ? ds => ds.EnvelopeId == request.Envelope.Id - : !string.IsNullOrWhiteSpace(request.Envelope.Uuid) - ? ds => ds.Envelope.Uuid == request.Envelope.Uuid - : throw new BadRequestException(); - - // receiver filter - Expression>? rExp = - request.Receiver.Id is not null - ? ds => ds.ReceiverId == request.Receiver.Id - : request.Receiver.EmailAddress is not null - ? ds => ds.Receiver.EmailAddress == request.Receiver.EmailAddress - : !string.IsNullOrWhiteSpace(request.Receiver.Signature) ? ds => ds.Receiver.Signature == request.Receiver.Signature - : throw new BadRequestException(); - // ceck if exists - bool isExists = await _repo.ReadOnly().Where(eExp).Where(rExp).AnyAsync(cancel); + bool isExists = await _repo.ReadOnly().Where(request).AnyAsync(cancel); if (isExists) { var uReq = request.To(); - await _repo.UpdateAsync(uReq, q => q.Where(eExp).Where(rExp), cancel); + await _repo.UpdateAsync(uReq, q => q.Where(request), cancel); } else { @@ -91,7 +73,7 @@ public class SaveDocStatusCommandHandler : IRequestHandler