public async Task <ActionResult> Create(ToDoStatusViewModel item) { try { var todoItem = new ToDoItem() { Title = item.Title, ToDoStatusId = item.ToDoStatusId }; var user = await GetCurrentUserAsync(); todoItem.ApplicationUserId = user.Id; _context.ToDoItem.Add(todoItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(View()); } }
private void AddNewToDoItem(ToDoItem item) { item.DateCreated = DateTime.Now; _context.Add(item); _context.SaveChanges(); }
public IActionResult Edit(int Id) { ToDoItem td = _db.ToDoItem.Find(Id); return(View(td)); }
public IActionResult Delete(ToDoItem td) { _db.ToDoItem.Remove(td); _db.SaveChanges(); return(RedirectToAction("ListTasks")); }