示例#1
0
        // PUT api/Todo/5
        public HttpResponseMessage PutTodoItem(int id, TodoItem todoitem)
        {
            if (ModelState.IsValid && id == todoitem.TodoItemId)
            {
                db.Entry(todoitem).State = EntityState.Modified;

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

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
示例#2
0
 public IActionResult Edit(Item item)
 {
     db.Entry(item).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#3
0
 public IActionResult Edit(Category category)
 {
     db.Entry(category).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }