Esempio n. 1
0
        // PUT: odata/Products(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <Product> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Product product = db.Products.Find(key);

            if (product == null)
            {
                return(NotFound());
            }

            patch.Put(product);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(product));
        }
        // PUT: odata/StockIns(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <StockIn> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            StockIn stockIn = db.StockIns.Find(key);

            if (stockIn == null)
            {
                return(NotFound());
            }

            patch.Put(stockIn);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StockInExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(stockIn));
        }
        // PUT: odata/Orders(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <Order> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Order order = db.Orders.Find(key);

            if (order == null)
            {
                return(NotFound());
            }

            patch.Put(order);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(order));
        }