Exemplo n.º 1
0
        public IHttpActionResult Post([FromBody] ShopDto shopDto)
        {
            var shop = shopDto.ToModel();

            shop.CreatedDate = System.DateTime.Now;

            shoppingEntities.Shops.Add(shop);
            shoppingEntities.SaveChanges();

            return(Ok(new ShopDto(shop)));
        }
Exemplo n.º 2
0
        public IHttpActionResult Put([FromUri] Guid shopId, [FromBody] ShopDto shopDto)
        {
            Shop shop = shoppingEntities.Shops.FirstOrDefault(t => t.Id == shopId);

            if (shop == null)
            {
                throw new BadRequestException("Không tìm thấy Shop");
            }

            shopDto.ToModel(shop);
            shoppingEntities.SaveChanges();

            return(Ok(new ShopDto(shop)));
        }