public ShipmentEntity Create(ShipmentEntity ShipmentEntity) { Shipment shipment = ShipmentEntity.ToModel(); smartDeliveryContext.Shipment.Add(shipment); smartDeliveryContext.SaveChanges(); return(new ShipmentEntity(shipment)); }
public ShipmentEntity Update(Guid ShipmentId, ShipmentEntity ShipmentEntity) { Shipment shipments = smartDeliveryContext.Shipment.Where(m => m.Id == ShipmentId).FirstOrDefault(); if (shipments == null) { throw new BadRequestException("Shipment khong ton tai"); } ShipmentEntity.ToModel(shipments); smartDeliveryContext.Shipment.Update(shipments); smartDeliveryContext.SaveChanges(); return(new ShipmentEntity(shipments)); }