private void LoadTasks() { if (TaskStateColumns == null || !TaskStateColumns.Any()) { return; } foreach (var taskStateColumn in TaskStateColumns) { taskStateColumn.Tasks.Clear(); } foreach (var task in _taskQueryService.GetAll().OrderByDescending(x => x.Priority).ThenBy(x => x.Title)) { try { var taskColumn = TaskStateColumns.First(taskStateColumn => taskStateColumn.TaskState.Name == task.State); taskColumn.Tasks.Add(new TaskDetailsViewModel(task, _taskQueryService, _taskStateQueryService, _repositoryService)); } catch (Exception) { // ignored } } }
private void TaskQueryServiceOnElementDeleted(Task task) { try { var taskColumn = TaskStateColumns.First(stateColumn => stateColumn.TaskState.Name == task.State); var taskViewModel = taskColumn.Tasks.First(taskVm => taskVm.Task.Title == task.Title); taskColumn.Tasks.Remove(taskViewModel); } catch (Exception) { // ignored } }
private void TaskQueryServiceOnElementAdded(Task task) { try { var taskColumn = TaskStateColumns.First(stateColumn => stateColumn.TaskState.Name == task.State); taskColumn.Tasks.Add(new TaskDetailsViewModel(task, _taskQueryService, _taskStateQueryService, _repositoryService)); var tasks = taskColumn.Tasks.ToList(); taskColumn.Tasks.Clear(); foreach (var taskVm in tasks.OrderByDescending(x => x.Task.Priority).ThenBy(x => x.Task.Title)) { taskColumn.Tasks.Add(taskVm); } } catch (Exception) { // ignored } }