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
     }
 }
        public void InitializeTaskStateColumns()
        {
            TaskStateColumns.Clear();
            var orderedTaskStates = _taskStateQueryService.GetAll().OrderBy(x => x.Position);
            var count             = orderedTaskStates.Count();
            var counter           = 0;

            foreach (var state in orderedTaskStates)
            {
                var isOpened        = counter < DefaultOpenedColumnsCount;
                var taskStateColumn = new TaskStateColumnViewModel(state, _taskStateQueryService, _filtersViewModel, counter,
                                                                   isOpened, counter > 0, counter < count - 1);
                taskStateColumn.PropertyChanged += TaskStateColumnOnPropertyChanged;
                TaskStateColumns.Add(taskStateColumn);
                counter++;
            }

            OpenedColumnsCount = Math.Min(counter, DefaultOpenedColumnsCount);
            HiddenColumnsCount = Math.Max(0, counter - OpenedColumnsCount);
        }