public ShipmentGoodEntity Create(ShipmentGoodEntity ShipmentGoodEntity) { ShipmentGoods shipmentGood = ShipmentGoodEntity.ToModel(); smartDeliveryContext.ShipmentGoods.Add(shipmentGood); smartDeliveryContext.SaveChanges(); return(new ShipmentGoodEntity(shipmentGood)); }
public ShipmentGoodEntity Update(Guid ShipmentGoodId, ShipmentGoodEntity ShipmentGoodEntity) { ShipmentGoods shipmentGood = smartDeliveryContext.ShipmentGoods.Where(m => m.Id == ShipmentGoodId) .Include(u => u.Goods) .Include(u => u.Shipment) .FirstOrDefault(); if (shipmentGood == null) { throw new BadRequestException("ShipmentGood khong ton tai"); } ShipmentGoodEntity.ToModel(shipmentGood); smartDeliveryContext.ShipmentGoods.Update(shipmentGood); smartDeliveryContext.SaveChanges(); return(new ShipmentGoodEntity(shipmentGood)); }