예제 #1
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta <ReasonForTransfer> patch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ReasonForTransfer reasonfortransfer = db.ReasonForTransfers.Find(key);

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

            patch.Patch(reasonfortransfer);

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

            return(Updated(reasonfortransfer));
        }
예제 #2
0
        // PUT odata/ReasonsForTransfer(5)
        public IHttpActionResult Put([FromODataUri] int key, ReasonForTransfer reasonfortransfer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (key != reasonfortransfer.Id)
            {
                return(BadRequest());
            }

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

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

            return(Updated(reasonfortransfer));
        }
예제 #3
0
        // POST odata/ReasonsForTransfer
        public IHttpActionResult Post(ReasonForTransfer reasonfortransfer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ReasonForTransfers.Add(reasonfortransfer);
            db.SaveChanges();

            return(Created(reasonfortransfer));
        }
예제 #4
0
        // DELETE odata/ReasonsForTransfer(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            ReasonForTransfer reasonfortransfer = db.ReasonForTransfers.Find(key);

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

            db.ReasonForTransfers.Remove(reasonfortransfer);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }