public ShipperEntity Create(ShipperEntity shipperEntity) { Shipper shipper = shipperEntity.ToModel(); User User = new User(); User.Id = shipperEntity.Id; User.Username = shipperEntity.Name; User.Password = "******"; smartDeliveryContext.User.Add(User); smartDeliveryContext.Shipper.Add(shipper); smartDeliveryContext.SaveChanges(); return(new ShipperEntity(shipper)); }
public ShipperEntity Update(Guid ShipperId, ShipperEntity ShipperEntity) { Shipper shipper = smartDeliveryContext.Shipper.Where(m => m.Id == ShipperId) .Include(u => u.IdNavigation) .FirstOrDefault(); if (shipper == null) { throw new BadRequestException("Shipper khong ton tai"); } ShipperEntity.ToModel(shipper); smartDeliveryContext.Shipper.Update(shipper); smartDeliveryContext.SaveChanges(); return(new ShipperEntity(shipper)); }
public ShipperEntity Update(Guid shipperId, [FromBody] ShipperEntity shipperEntity) { return(shipperService.Update(shipperId, shipperEntity)); }
public ShipperEntity Create([FromBody] ShipperEntity customerEntity) { return(shipperService.Create(customerEntity)); }