Ejemplo n.º 1
0
 void loadCommonData()
 {
     var commonDataLoader = new CommonDataLoader(new RestRequestCreator());
     // 20141030
     // CommonData.Data = commonDataLoader.Load();
     ClientSettings.Instance.CommonData.Data = commonDataLoader.Load();
 }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (!await HttpHelper.CheckInternet())
            {
                Progress.Text = "加载资源失败";
                await new MessageDialog("请连接互联网后重试!").ShowAsync();
                Windows.UI.Xaml.Application.Current.Exit();
            }

            HomePage.TodaysListId = await CommonDataLoader.GetGeneralList(HomePage.CumulateListIndex.ToString(), ListType.HomeList);

            HomePage.CumulateListIndex += 1;
            Progress.Text = "加载资源成功!正在初始化";

            Frame.ContentTransitions = new TransitionCollection {
                new NavigationThemeTransition()
            };

            NavigationManager.GeneralFrame = Frame;
            Frame.Navigate(
                ViewModelBase.CurrentSettings.SkipPreLoadPage ? typeof(MainFrameContainer) : typeof(PreLoadPage),
                HomePage.CurrentHomeModle = await CommonDataLoader.GetGeneralModelByIdAsync <HomeModel>(HomePage.TodaysListId[0]),
                new DrillInNavigationTransitionInfo());

            SystemNavigationManager.GetForCurrentView().BackRequested += PreLoadPage_BackRequested;
        }
 public async Task RefreshListView()
 {
     foreach (var item in await CommonDataLoader.GetReadingModel(0))
     {
         ReadingModelCollection.Add(item);
     }
 }
 public async Task RefreshCollection()
 {
     foreach (var item in await CommonDataLoader.GetGeneralModelsCollectionByIdAsync <CarouselModel>(""))
     {
         AddToCollection(item);
     }
 }
Ejemplo n.º 5
0
        public async Task RefreshAMusicCollection(string id)
        {
            var model = await CommonDataLoader.GetGeneralModelByIdAsync <MusicModel>(id);

            await model.RefreshCommentsCollection(string.Format(ServicesUrl.MusicComment, id));

            MusicModelsCollection.Add(model);
        }
 public async Task RefreshCollection(string id)
 {
     foreach (var item in await CommonDataLoader.GetGeneralModelsCollectionByIdAsync <CarouselDetailModel>(id))
     {
         CarouselDetailModelCollection.Add(item);
     }
     CarouselDetailModel.ResetIndex();
 }
 public async Task RefreshCommentsCollection(string id)
 {
     foreach (var model in await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <CommentModel>(string.Format(ServicesUrl.MovieComment, Id)))
     {
         if (model.Type == "0")
         {
             HotComments.Add(model);
         }
         else
         {
             NormalComments.Add(model);
         }
     }
 }
Ejemplo n.º 8
0
        public static async Task <string> RequestUpdate()
        {
            try
            {
                var response = (await CommonDataLoader.GetGeneralList("0", ListType.HomeList)).Take(5);

                if (response != null)
                {
                    await UpdatePrimaryTile((await CommonDataLoader.LoadHomeModelsAsync(response)).ToList());
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(null);
        }
Ejemplo n.º 9
0
        protected async Task AddToRelatedCollection <T>(string id)
        {
            var uri = GetRelatedUri <T>(id);

            switch (typeof(T).Name)
            {
            case nameof(QuestionDetailPageViewModel):
                AddToRelatedCollection <QuestionContent, QuestionModel>(
                    await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <QuestionContent>(uri));
                return;

            case nameof(EssayDetailPageViewModel):
                AddToRelatedCollection <EssayContent, EssayModel>(
                    await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <EssayContent>(uri));
                return;

            case nameof(SerialDetailPageViewModel):
                AddToRelatedCollection <SerialContent, SerialModel>(
                    await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <SerialContent>(uri)
                    );
                return;
            }
        }
Ejemplo n.º 10
0
 public void Should_respond_Ok_on_getting_common_data_as_json()
 {
     var url = GIVEN_url_to_testRun_data();
     _responseHeaders.Location = new Uri(BaseUrl + url);
     _mockRestServer.ExpectNewRequest()
         .AndExpectUri(BaseUrl + url)
         .AndExpectMethod(HttpMethod.GET)
         .AndRespondWith("{ \"Key\":\"aaa\",\"Value\":\"bbb\" }", _responseHeaders, HttpStatusCode.OK, "");
     
     var commonDataLoader = new CommonDataLoader(_restRequestCreator);
     var resultDictionary = commonDataLoader.Load();
     
     Assert.Equal("aaa", resultDictionary["Key"]);
     Assert.Equal("bbb", resultDictionary["Value"]);
 }
Ejemplo n.º 11
0
 public async Task AddHomeModel(string contentId)
 {
     _homeModelCollection.Add(await CommonDataLoader.GetGeneralModelByIdAsync <HomeModel>(contentId));
 }