public async Task<IActionResult> Edit(int id, [Bind("ToDoItemId,Item,DateDue,Done,UserId,CategoryId")] ToDoItem toDoItem) { if (id != toDoItem.ToDoItemId) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(toDoItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToDoItemExists(toDoItem.ToDoItemId)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryName", toDoItem.CategoryId); ViewData["UserId"] = new SelectList(_context.Users, "UserId", "UserName", toDoItem.UserId); return View(toDoItem); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,UserName,LastLoggedIn")] User user) { if (id != user.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("CategoryId,CategoryName")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }