예제 #1
0
        public IHttpActionResult PuttSalesOrderLine(int id, tSalesOrderLine tSalesOrderLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tSalesOrderLine.ID)
            {
                return(BadRequest());
            }

            db.Entry(tSalesOrderLine).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult PuttSalesOrderLine(tSalesOrderLine tSalesOrderLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                foreach (var item in db.tSalesOrderLines.Where(x => x.SalesOrderID == tSalesOrderLine.SalesOrderID))
                {
                    item.SAP_SalesOrderID = tSalesOrderLine.SAP_SalesOrderID;
                }

                db.SaveChanges();

                return(StatusCode(HttpStatusCode.OK));
            }
            catch (DbUpdateConcurrencyException)
            {
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public IHttpActionResult UpdatetSalesOrderLinesTransactionStatus(tSalesOrderLine tSalesOrderLine)
        {
            var             headerID = tSalesOrderLine.SalesOrderID;
            var             lineID   = tSalesOrderLine.SalesOrderLineID;
            tSalesOrderLine existing = new tSalesOrderLine();

            existing = db.tSalesOrderLines.Where(x => x.SalesOrderID == headerID && x.SalesOrderLineID == lineID).SingleOrDefault();

            if (existing != null)
            {
                existing.TransactionStatus = tSalesOrderLine.TransactionStatus;
            }

            db.Entry(existing).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tSalesOrderLineExists(headerID, lineID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.OK));
        }
예제 #4
0
        public IHttpActionResult GettSalesOrderLine(int id)
        {
            tSalesOrderLine tSalesOrderLine = db.tSalesOrderLines.Find(id);

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

            return(Ok(tSalesOrderLine));
        }
예제 #5
0
        public IHttpActionResult PosttSalesOrderLine(tSalesOrderLine tSalesOrderLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tSalesOrderLines.Add(tSalesOrderLine);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tSalesOrderLine.ID }, tSalesOrderLine));
        }
예제 #6
0
        public IHttpActionResult DeletetSalesOrderLine(int id)
        {
            tSalesOrderLine tSalesOrderLine = db.tSalesOrderLines.Find(id);

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

            db.tSalesOrderLines.Remove(tSalesOrderLine);
            db.SaveChanges();

            return(Ok(tSalesOrderLine));
        }
예제 #7
0
        public IHttpActionResult PosttSalesOrderLine(tSalesOrderLine tSalesOrderLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                db.tSalesOrderLines.Add(tSalesOrderLine);
                db.SaveChanges();
                return(StatusCode(HttpStatusCode.OK));
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;

                    switch (entry.State)
                    {
                    case EntityState.Added:
                        entry.State = EntityState.Detached;
                        return(BadRequest());

                    //break;
                    case EntityState.Modified:
                        entry.CurrentValues.SetValues(entry.OriginalValues);
                        entry.State = EntityState.Unchanged;
                        return(BadRequest());

                    //break;
                    case EntityState.Deleted:
                        entry.State = EntityState.Unchanged;
                        return(BadRequest());
                        //break;
                    }
                }
            }

            return(BadRequest());
        }