コード例 #1
0
        public TestItemType Patch([FromODataUri] int key, Delta <TestItemType> patch)
        {
            TestItemType testitemtype = db.TestItemTypes.Find(key);

            patch.Patch(testitemtype);

            db.SaveChanges();

            return(testitemtype);
        }
コード例 #2
0
        // PUT api/TestItemTypes/5
        public HttpResponseMessage PutTestItemType(int id, TestItemType testitemtype)
        {
            if (ModelState.IsValid && id == testitemtype.Id)
            {
                db.Entry(testitemtype).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
コード例 #3
0
 public Article Post(Article item)
 {
     db.Articles.Add(item);
     db.SaveChanges();
     return(item);
 }