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))); }
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))); }