示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
 public IHttpActionResult DeleteShop_sProduct(long id)
 {
     if (ShopProductsBLL.DeleteShopProducts(id) == false)
     {
         return(NotFound());
     }
     return(Ok());
 }
示例#4
0
        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));
        }
示例#7
0
 // GET: api/Shop_sProduct
 public IHttpActionResult GetShop_sProduct()
 {
     return(Ok(ShopProductsBLL.GetAllShopProducts()));
 }
示例#8
0
 private bool Shop_sProductExists(long id)
 {
     return(ShopProductsBLL.ShopProductsExists(id));
 }