public IActionResult Details(int?id) { ToDoTask task = _toDoTaskService.GetAllTasks().SingleOrDefault(x => x.Id == id); List <SubTaskViewModel> subTasksModel = new List <SubTaskViewModel>(); foreach (var subTask in task.SubTask) { subTasksModel.Add(new SubTaskViewModel() { Id = subTask.Id, Title = subTask.Title, Description = subTask.Description, Status = subTask.Status, ToDoTaskId = subTask.ToDoTaskId }); } TaskViewModel model = new TaskViewModel() { Id = task.Id, Title = task.Title, Description = task.Description, Priority = task.Priority, Status = task.Status, TypeOfTask = task.TypeOfTask, SubTask = subTasksModel }; return(View(model)); }
public IActionResult Details(int?id) { ToDoTask task = _toDoTaskService.GetAllTasks().SingleOrDefault(x => x.Id == id); TaskViewModel model = new TaskViewModel() { Id = task.Id, Title = task.Title, Description = task.Description, Priority = task.Priority, Status = task.Status, TypeOfTask = task.TypeOfTask, }; return(View(model)); }
public IActionResult Index() { List <AllTasksViewModel> taskViewModel = new List <AllTasksViewModel>(); var tasks = _taskService.GetAllTasks(); foreach (var task in tasks) { taskViewModel.Add(new AllTasksViewModel() { Title = task.Title, Description = task.Description, Priority = task.Priority, Status = task.Status, TaskType = task.TaskType, SubTasks = task.SubTasks }); } return(View(taskViewModel)); }