Пример #1
0
        public async Task <IActionResult> PutTodoNote([FromRoute] int id, [FromBody] TodoNote todoNote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != todoNote.Id)
            {
                return(BadRequest());
            }

            _context.Entry(todoNote).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TodoNoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,Name")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #3
0
 public ActionResult Edit([Bind(Include = "Id,Title,Description,IsComplete,TodoListId")] Todo todo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(todo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TodoListId = new SelectList(db.TodoLists, "Id", "Name", todo.TodoListId);
     return(View(todo));
 }
Пример #4
0
 public ActionResult Edit([Bind(Include = "Id,Name,UserId")] TodoList todoList)
 {
     if (ModelState.IsValid)
     {
         db.Entry(todoList).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "Name", todoList.UserId);
     return(View(todoList));
 }