Example #1
0
        public IHttpActionResult PostInwardDelItem(InwardDelItem inwardDelItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.InwardDelItems.Add(inwardDelItem);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (InwardDelItemExists(inwardDelItem.InwardDelItemID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = inwardDelItem.InwardDelItemID }, inwardDelItem));
        }
Example #2
0
        public IHttpActionResult PutInwardDelItem(string id, InwardDelItem inwardDelItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != inwardDelItem.InwardDelItemID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public IHttpActionResult GetInwardDelItem(string id)
        {
            InwardDelItem inwardDelItem = db.InwardDelItems.Find(id);

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

            return(Ok(inwardDelItem));
        }
Example #4
0
        public IHttpActionResult DeleteInwardDelItem(string id)
        {
            InwardDelItem inwardDelItem = db.InwardDelItems.Find(id);

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

            db.InwardDelItems.Remove(inwardDelItem);
            db.SaveChanges();

            return(Ok(inwardDelItem));
        }