void OnTaskUpdated(object sender, TaskUpdatedEventArgs e)
        {
            this.ChildTasks.Remove(this.ChildTasks.FirstOrDefault(t => t.TaskId == e.UpdatedTask.TaskId));
            var viewModel = new TaskViewModel(e.UpdatedTask, _taskData);

            this.ChildTasks.Add(viewModel);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the all tasks cached query results when a task is updated
        /// </summary>
        void AllTasksOnTaskUpdated(object sender, TaskUpdatedEventArgs e)
        {
            QueryCacheItem cachedQuery = _appInfo.GlobalQueryCache.GetCacheItem(Constants.AllTasksCacheItem);

            if (cachedQuery != null)
            {
                // updated the query results if needed
                List <Data.Task> allTasks = (List <Data.Task>)cachedQuery.Value;
                Data.Task        oldTask  = allTasks.FirstOrDefault(t => t.TaskID == e.UpdatedTask.TaskId);
                Data.Task        newTask  = e.UpdatedDbTask;
                if (oldTask != null && newTask != null)
                {
                    allTasks.Remove(oldTask);
                    allTasks.Add(newTask);
                }
                else if (newTask != null)
                {
                    allTasks.Add(newTask);
                }

                allTasks = SortList(allTasks);

                _appInfo.GlobalQueryCache.UpdateCacheItem(Constants.AllTasksCacheItem, allTasks);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the active tasks cached query results when a task is updated
        /// </summary>
        void ActiveTasksOnTaskUpdated(object sender, TaskUpdatedEventArgs e)
        {
            QueryCacheItem cachedQuery = _appInfo.GlobalQueryCache.GetCacheItem(Constants.ActiveTasksCacheItem);

            if (cachedQuery != null)
            {
                // updated the query results if needed
                List <Data.Task> activeTasks = (List <Data.Task>)cachedQuery.Value;
                if (e.UpdatedTask.IsActive)
                {
                    Data.Task oldTask = activeTasks.FirstOrDefault(t => t.TaskID == e.UpdatedTask.TaskId);
                    Data.Task newTask = e.UpdatedDbTask;
                    if (oldTask != null && newTask != null)
                    {
                        activeTasks.Remove(oldTask);
                        activeTasks.Add(newTask);
                    }
                    else if (newTask != null)
                    {
                        activeTasks.Add(newTask);
                    }

                    activeTasks = SortList(activeTasks, new SortableProperty()
                    {
                        Description = "Sort Order", Name = "SortOrder"
                    });
                }
                else
                {
                    // the updated task doesnt meet the filter term so remove if it exists in list
                    Data.Task oldTask = activeTasks.FirstOrDefault(t => t.TaskID == e.UpdatedTask.TaskId);
                    if (oldTask != null)
                    {
                        activeTasks.Remove(oldTask);
                    }
                }

                _appInfo.GlobalQueryCache.UpdateCacheItem(Constants.ActiveTasksCacheItem, activeTasks);
            }
        }
Esempio n. 4
0
 void OnTaskUpdated(object sender, TaskUpdatedEventArgs e)
 {
     RefreshTasksAfterModification();
 }