public void EditTask(UiModel.Task task) { switch (task.Status) { case Status.New: UiModel.Task newTask = NewTasks.FirstOrDefault(t => t.Id == task.Id); if (newTask != null) { Mapper.Map(task, newTask); } else { DeleteFromList(RawTask); task.CompletedDate = null; NewTasks.Add(task); } break; case Status.InProgress: UiModel.Task inProgressTask = TasksInProgress.FirstOrDefault(t => t.Id == task.Id); if (inProgressTask != null) { Mapper.Map(task, inProgressTask); } else { DeleteFromList(RawTask); task.CompletedDate = null; TasksInProgress.Add(task); } break; case Status.Completed: UiModel.Task completedTask = TasksCompleted.FirstOrDefault(t => t.Id == task.Id); if (completedTask != null) { Mapper.Map(task, completedTask); } else { DeleteFromList(RawTask); task.CompletedDate = DateTime.Now; TasksCompleted.Add(task); } break; } }
public void CreateTask(UiModel.Task task) { task.Id = GetId(); task.CompletedDate = null; switch (task.Status) { case Status.New: NewTasks.Add(task); break; case Status.InProgress: TasksInProgress.Add(task); break; case Status.Completed: task.CompletedDate = DateTime.Now; TasksCompleted.Add(task); break; } }
public void DragAndDrop(String name, UiModel.Task task) { switch (name) { case nameof(NewTasks): if (task.Status != Status.New) { DeleteFromList(task); task.Status = Status.New; task.CompletedDate = null; NewTasks.Add(task); TaskService.Update(Mapper.Map <DataModel.Task>(task)); } break; case nameof(TasksInProgress): if (task.Status != Status.InProgress) { DeleteFromList(task); task.CompletedDate = null; task.Status = Status.InProgress; TasksInProgress.Add(task); TaskService.Update(Mapper.Map <DataModel.Task>(task)); } break; case nameof(TasksCompleted): if (task.Status != Status.Completed) { DeleteFromList(task); task.CompletedDate = DateTime.Now; task.Status = Status.Completed; TasksCompleted.Add(task); TaskService.Update(Mapper.Map <DataModel.Task>(task)); } break; } }