Пример #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));
        }