Пример #1
0
        private async void OrphanMasterDetailPage_Loaded(object sender, RoutedEventArgs e)
        {
            await LoadOrphansAsync();

            if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both)
            {
                Selected = OrphanItems.FirstOrDefault();
            }
        }
Пример #2
0
        private async Task LoadOrphansAsync()
        {
            //SampleItems.Clear();
            OrphanItems.Clear();

            IEnumerable <Orphan> data;

            //
            // Use Web API or db directly
            //
            if (AppSettings.UseWebApi)
            {
                using (HttpClient client = new HttpClient())
                {
                    var orphanRepo = new OrphanHttpRepository(client);
                    var parameters = new OrphanParametes
                    {
                        PageNumber = 1,
                        PageSize   = 1000
                    };
                    var response = await orphanRepo.GetOrphansAsync(parameters);

                    data = response.Orphans.AsEnumerable();
                }
            }
            else
            {
                data = await OrphanDataService.AllOrphans();

                using (HttpClient client = new HttpClient())
                {
                    var orphanRepo = new PictureHttpRepository(client);
                    var picUrls    = await orphanRepo.GetOrphanPicUrls();

                    foreach (var item in picUrls)
                    {
                        var orphan = data.FirstOrDefault(x => x.OrphanID == item.OrphanID);
                        if (orphan != null)
                        {
                            orphan.ProfilePicUri = item.PicUrl;
                        }
                    }
                }
            }

            //var data = await SampleDataService.GetMasterDetailDataAsync();
            //var data = await OrphanDataService.AllOrphans();

            foreach (var item in data)
            {
                //SampleItems.Add(item);
                OrphanItems.Add(item);
            }

            if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both)
            {
                Selected = OrphanItems.FirstOrDefault();

                LoadNarrationItems();
            }
        }