示例#1
0
        /// <summary>
        /// Updates the all goals cached query results when a goal is updated
        /// </summary>
        void AllGoalsOnGoalUpdated(object sender, GoalUpdatedEventArgs e)
        {
            QueryCacheItem cachedQuery = _appInfo.GlobalQueryCache.GetCacheItem(Constants.AllGoalsCacheItem);

            if (cachedQuery != null)
            {
                // updated the query results if needed
                List <Data.Goal> allGoals = (List <Data.Goal>)cachedQuery.Value;
                Data.Goal        oldGoal  = allGoals.FirstOrDefault(g => g.GoalID == e.UpdatedGoal.GoalId);
                Data.Goal        newGoal  = e.UpdatedDbGoal;
                if (oldGoal != null && newGoal != null)
                {
                    allGoals.Remove(oldGoal);
                    allGoals.Add(newGoal);
                }
                else if (newGoal != null)
                {
                    allGoals.Add(newGoal);
                }

                allGoals = SortList(allGoals);

                _appInfo.GlobalQueryCache.UpdateCacheItem(Constants.AllGoalsCacheItem, allGoals);
            }
        }
 void OnGoalUpdated(object sender, GoalUpdatedEventArgs e)
 {
     RefreshGoalsAfterModification();
 }