예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
 public ShipperEntity Update(Guid shipperId, [FromBody] ShipperEntity shipperEntity)
 {
     return(shipperService.Update(shipperId, shipperEntity));
 }
예제 #4
0
 public ShipperEntity Create([FromBody] ShipperEntity customerEntity)
 {
     return(shipperService.Create(customerEntity));
 }