public IActionResult EditTasks(Tasks updateTask) { Tasks dbTasks = _context.Tasks.Find(updateTask.Id); if (ModelState.IsValid) { dbTasks.TaskDescription = updateTask.TaskDescription; dbTasks.DueDate = updateTask.DueDate; dbTasks.Completed = updateTask.Completed; _context.Entry(dbTasks).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(dbTasks); _context.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult EditTasks(Tasks tasks) { Tasks foundTasks = _context.Tasks.Find(tasks.Id); if (ModelState.IsValid) { foundTasks.TaskDescription = tasks.TaskDescription; foundTasks.DueDate = tasks.DueDate; foundTasks.Completed = tasks.Completed; _context.Entry(foundTasks).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(foundTasks); _context.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult EditTask(Tasks updatedTask) { // updatedTask.TaskOwnerId = User.FindFirst(ClaimTypes.NameIdentifier).Value; Tasks dbtask = _context.Tasks.Find(updatedTask.Id); if (ModelState.IsValid) { dbtask.TaskDescription = updatedTask.TaskDescription; dbtask.DueDate = updatedTask.DueDate; dbtask.Completed = updatedTask.Completed; //May need to delete _context.Entry(dbtask).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(dbtask); _context.SaveChanges(); } return(RedirectToAction("Index")); }