public async Task <IActionResult> Create([Bind("ToDoItemID,UserEmail,Title,Description,AddedDate,DueDate,Done,DoneDate")] ToDoItem toDoItem) { if (ModelState.IsValid) { _context.Add(toDoItem); await _context.SaveChangesAsync(); toDoItem.UserEmail = User.Identity.Name; toDoItem.AddedDate = DateTime.Now.ToString(); toDoItem.DueDate = DateTime.Now.AddDays(1).ToString(); toDoItem.DoneDate = "Unknown"; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(toDoItem)); }
public async Task CreateToDoTask(ToDo toDo) { _context.Add(toDo); await _context.SaveChangesAsync(); }