using Netina.Domain.Entities.Orders; namespace Netina.Repository.Handlers.Orders; public class DeleteOrderCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler { public async Task Handle(DeleteOrderCommand request, CancellationToken cancellationToken) { var order = await repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken); if (order == null) throw new AppException("Order not found", ApiResultStatusCode.NotFound); repositoryWrapper.SetRepository().Delete(order); await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } }