Пример #1
0
        // POST: odata/ProductInventories
        public IHttpActionResult Post(FactProductInventory factProductInventory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.FactProductInventories.Add(factProductInventory);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (FactProductInventoryExists(factProductInventory.ProductKey, factProductInventory.DateKey))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(factProductInventory));
        }
Пример #2
0
        // DELETE: odata/ProductInventories(5)
        public IHttpActionResult Delete([FromODataUri] int keyProductKey, [FromODataUri] int keyDateKey)
        {
            FactProductInventory factProductInventory = db.FactProductInventories.Find(keyProductKey, keyDateKey);

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

            db.FactProductInventories.Remove(factProductInventory);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public IHttpActionResult Patch([FromODataUri] int keyProductKey, [FromODataUri] int keyDateKey, Delta <FactProductInventory> patch)
        {
            Validate(patch.GetInstance());

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

            FactProductInventory factProductInventory = db.FactProductInventories.Find(keyProductKey, keyDateKey);

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

            patch.Patch(factProductInventory);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FactProductInventoryExists(keyProductKey, keyDateKey))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(factProductInventory));
        }