예제 #1
0
 async void OnItemTapped(object sender, ItemTappedEventArgs e)
 {
     var itemSet = e.Item as StudyPlan;
     if (itemSet == null) return;
     if (AppCache.QuestionCache != null && Application.Current.Properties.ContainsKey("QuestionTemplate"))
     {
         object currentTemplate = null;
         if (Application.Current.Properties.TryGetValue("QuestionTemplate", out currentTemplate))
         {
             var currTemplate = currentTemplate as QuestionTemplate;
             List<Question> retList = null;
             if (currTemplate != null && AppCache.QuestionCache != null && AppCache.QuestionCache.ContainsKey(currTemplate.UniqueGuid))
             {
                 CurrentTemplate = currTemplate;
                 if (AppCache.QuestionCache.TryGetValue(currTemplate.UniqueGuid, out retList))
                 {
                     if (retList != null)
                     {
                         RefreshList(); //Saw some random error and adding this line to fix it
                         await Navigation.PushAsync(new QuestionListPage(retList, itemSet.Category, AppEnums.QuestionListFilter.StudyPlan));
                         
                         return;
                     }
                 }
             }
         }
     }
    
     var list = await AppCache.GetData(null, null);
     if (list != null && list.Count > 0)
         RefreshList(); //Saw some random error and adding this line to fix it
     await Navigation.PushAsync(new QuestionListPage(list, itemSet.Category, AppEnums.QuestionListFilter.StudyPlan));
     
 }
예제 #2
0
        private void RefreshList()
        {
            if (AppCache.QuestionCache != null && Application.Current.Properties.ContainsKey("QuestionTemplate"))
            {
                object currentTemplate = null;
                if (Application.Current.Properties.TryGetValue("QuestionTemplate", out currentTemplate))
                {
                    var currTemplate = currentTemplate as QuestionTemplate;
                    List<Question> retList = null;
                    if (currTemplate != null && AppCache.QuestionCache != null &&
                        AppCache.QuestionCache.ContainsKey(currTemplate.UniqueGuid))
                    {
                        CurrentTemplate = currTemplate;
                        if (AppCache.QuestionCache.TryGetValue(currTemplate.UniqueGuid, out retList))
                        {
                            if (retList != null)
                            {
                               
                                    foreach (var item in retList)
                                    {
                                        item.Refresh();
                                    }
                                

                            }
                        }
                    }
                }

            }
        }
예제 #3
0
파일: App.cs 프로젝트: lanreisee/ExamPrep
        //This is here because a new home page will be introduced - The selected template will be saved to application class
        private void CreateNewTemplate()
        {
            var curTemplate = new QuestionTemplate
            {
                CompanyName = "OIS",
                CurrentTemplate = new QuestionTemplateDetail
                {
                    FileName = "QuestionData.xml",
                    Version = "1",
                    YearReleased = new DateTime(2015,03,25),
                    Id = 1
                },
            };

            this.TemplateName = curTemplate;
            if (!Application.Current.Properties.ContainsKey("QuestionTemplate"))
            {
                Application.Current.Properties["QuestionTemplate"] = TemplateName;
            }
        }
예제 #4
0
        private void SaveInCache(List<Question> list)
        {
            if (CurrentTemplate == null)
            {
                object currentTemplate = null;

                if (Application.Current.Properties.TryGetValue("QuestionTemplate", out currentTemplate))
                {
                    var currTemplate = currentTemplate as QuestionTemplate;
                    if (currentTemplate != null)
                    {
                        CurrentTemplate = currTemplate;
                    }
                    else
                    {
                        //throw application wide exception
                    }
                }
            }
            if (CurrentTemplate != null && !AppCache.QuestionCache.ContainsKey(CurrentTemplate.UniqueGuid))
            {
                AppCache.QuestionCache.Add(CurrentTemplate.UniqueGuid, list);
            }
            else
            {
               //throw application wide exception
            }
        }