Generator Changes at 11/16/2025 12:48:45 AM +03:30

This commit is contained in:
masoodafar-web
2025-11-16 00:53:15 +03:30
parent 974f3c788f
commit 0a649325f8
75 changed files with 1460 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
using CMSMicroservice.Domain.Events;
namespace CMSMicroservice.Application.ContractCQ.Commands.DeleteContract;
public class DeleteContractCommandHandler : IRequestHandler<DeleteContractCommand, Unit>
{
private readonly IApplicationDbContext _context;
public DeleteContractCommandHandler(IApplicationDbContext context)
{
_context = context;
}
public async Task<Unit> Handle(DeleteContractCommand request, CancellationToken cancellationToken)
{
var entity = await _context.Contracts
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Contract), request.Id);
entity.IsDeleted = true;
_context.Contracts.Update(entity);
entity.AddDomainEvent(new DeleteContractEvent(entity));
await _context.SaveChangesAsync(cancellationToken);
return Unit.Value;
}
}