public IHttpActionResult PostShop_sProduct(Shop_sProduct shop_sProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ShopProductsBLL.Add(shop_sProduct); try { Global.SaveChanges(); } catch (DbUpdateException) { if (Shop_sProductExists(shop_sProduct.productCode)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = shop_sProduct.productCode }, shop_sProduct)); }
public IHttpActionResult PutShop_sProduct(long id, Shop_sProduct shop_sProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shop_sProduct.productCode) { return(BadRequest()); } ShopProductsBLL.Entry(shop_sProduct); try { Global.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Shop_sProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult DeleteShop_sProduct(long id) { if (ShopProductsBLL.DeleteShopProducts(id) == false) { return(NotFound()); } return(Ok()); }
public IHttpActionResult GetShop_sProduct(long id) { ShopProductsDTO shop = ShopProductsBLL.GetShopProductsById(id); if (shop == null) { return(NotFound()); } return(Ok(shop)); }
public IHttpActionResult PutShop_sProduct([FromBody] List <ShopProductsDTO> shop_sProducts) { try { ShopProductsBLL.updateShopProducts(shop_sProducts); return(Ok()); } catch (Exception) { throw; } }
public IHttpActionResult PostShop_sProduct(ShopProductsDTO shop_sProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //TimeSpan time = TimeSpan.Parse(shop_sProduct.duration.ToString()); ////string ts = TimeSpan.fromMinutes(this.prepareTime); //shop_sProduct.duration = time; ShopProductsDTO sRes = ShopProductsBLL.Add(shop_sProduct); return(Ok(sRes)); }
// GET: api/Shop_sProduct public IHttpActionResult GetShop_sProduct() { return(Ok(ShopProductsBLL.GetAllShopProducts())); }
private bool Shop_sProductExists(long id) { return(ShopProductsBLL.ShopProductsExists(id)); }