コード例 #1
0
        public IHttpActionResult PutCustodyType(string id, CustodyType custodyType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != custodyType.custodyType1)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult PostCustodyType(CustodyType custodyType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CustodyType.Add(custodyType);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (CustodyTypeExists(custodyType.custodyType1))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = custodyType.custodyType1 }, custodyType));
        }
コード例 #3
0
        public IHttpActionResult DeleteCustodyType(string id)
        {
            CustodyType custodyType = db.CustodyType.Find(id);

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

            db.CustodyType.Remove(custodyType);
            db.SaveChanges();

            return(Ok(custodyType));
        }