using Netina.Domain.Entities.Warehouses; namespace Netina.Repository.Handlers.Warehouses; public class UpdateShippingCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler { public async Task Handle(UpdateShippingCommand request, CancellationToken cancellationToken) { var ent = await repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (ent == null) throw new AppException("Shipping not found", ApiResultStatusCode.NotFound); var newEnt = Shipping.Create(request.Name, request.WarehouseName, request.IsExpressShipping, request.IsShipBySeller, request.IsOriginalWarehouse,request.DeliveryCost,request.WorkingDays); newEnt.Id = ent.Id; newEnt.CreatedAt = ent.CreatedAt; newEnt.CreatedBy = ent.CreatedBy; repositoryWrapper.SetRepository().Update(newEnt); await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } }