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 DeleteFromList(UiModel.Task task) { switch (task.Status) { case Status.New: NewTasks.Remove(NewTasks.FirstOrDefault(t => t.Id == task.Id)); break; case Status.InProgress: TasksInProgress.Remove(TasksInProgress.FirstOrDefault(t => t.Id == task.Id)); break; case Status.Completed: TasksCompleted.Remove(TasksCompleted.FirstOrDefault(t => t.Id == task.Id)); break; } }