public async Task<IActionResult> Create(ToDo todo) { var currentUser = await _userManager.FindByIdAsync(User.GetUserId()); try { todo.User = currentUser; _db.ToDoes.Add(todo); _db.SaveChanges(); return RedirectToAction("Index"); } catch(Exception ex) { System.Diagnostics.Debug.Write(ex); return View(todo); } }
public IActionResult Edit (ToDo todo) { _db.Entry(todo).State = EntityState.Modified; _db.SaveChanges(); return RedirectToAction("Index"); }