public ViewResult Edit(int taskId) { Projecttask task = taskRepository.Tasks .FirstOrDefault(t => t.TaskId == taskId); return(View(task)); }
public ActionResult Deletetask(int taskId, int projectId = 0) { Projecttask deletedTask = taskRepository.DeleteTask(taskId); if (deletedTask != null) { TempData["message"] = string.Format("{0} was deleted", deletedTask.TaskName); } return(RedirectToAction("Details", "Project", new { projectId = projectId })); }
public Projecttask DeleteTask(int taskId) { Projecttask dbEntry = context.Tasks.Find(taskId); if (dbEntry != null) { context.Tasks.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public ActionResult Edit(Projecttask task) { if (ModelState.IsValid) { taskRepository.SaveTask(task); TempData["message"] = string.Format("{0} has been saved", task.TaskName); return(RedirectToAction("Details", new { projectId = task.ProjectId })); } else { return(View(task)); } }
public void SaveTask(Projecttask task) { if (task.TaskId == 0) { context.Tasks.Add(task); } else { Projecttask dbEntry = context.Tasks.Find(task.TaskId); if (dbEntry != null) { dbEntry.ProjectId = task.ProjectId; dbEntry.TaskName = task.TaskName; } } context.SaveChanges(); }