示例#1
0
        // POST: odata/ResellerSales
        public IHttpActionResult Post(FactResellerSale factResellerSale)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.FactResellerSales.Add(factResellerSale);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (FactResellerSaleExists(factResellerSale.SalesOrderNumber, factResellerSale.SalesOrderLineNumber))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(factResellerSale));
        }
示例#2
0
        // DELETE: odata/ResellerSales(5)
        public IHttpActionResult Delete([FromODataUri] string keySalesOrderNumber, [FromODataUri] byte keySalesOrderLineNumber)
        {
            FactResellerSale factResellerSale = db.FactResellerSales.Find(keySalesOrderNumber, keySalesOrderLineNumber);

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

            db.FactResellerSales.Remove(factResellerSale);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        // PUT: odata/ResellerSales(5)
        public IHttpActionResult Put([FromODataUri] string keySalesOrderNumber, [FromODataUri] byte keySalesOrderLineNumber, Delta <FactResellerSale> patch)
        {
            Validate(patch.GetInstance());

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

            FactResellerSale factResellerSale = db.FactResellerSales.Find(keySalesOrderNumber, keySalesOrderLineNumber);

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

            patch.Put(factResellerSale);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FactResellerSaleExists(keySalesOrderNumber, keySalesOrderLineNumber))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(factResellerSale));
        }