Beispiel #1
0
        /// <summary>
        /// When navigate to this page, request an api based on the given url
        /// If this character has url-based detail, requests those too
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="mode"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            try
            {
                var characterUrl = (string)parameter;
                var service      = new ThroneService();
                Character = await service.GetCharacterAsync(characterUrl);

                Father = await service.GetCharacterAsync(Character.Father);

                Mother = await service.GetCharacterAsync(Character.Mother);

                Spouse = await service.GetCharacterAsync(Character.Spouse);

                if (Character.Allegiances.Length != 0)
                {
                    Allies.Clear();
                    foreach (String url in Character.Allegiances)
                    {
                        House newHouse = await service.GetHouseAsync(url);

                        Allies.Add(newHouse);
                    }
                }

                if (Character.Books.Length != 0)
                {
                    Books.Clear();
                    foreach (String url in Character.Books)
                    {
                        Book newBook = await service.GetBookAsync(url);

                        Books.Add(newBook);
                    }
                }

                if (Character.PovBooks.Length != 0)
                {
                    PovBooks.Clear();
                    foreach (String url in Character.PovBooks)
                    {
                        Book newBook = await service.GetBookAsync(url);

                        PovBooks.Add(newBook);
                    }
                }

                await base.OnNavigatedToAsync(parameter, mode, state);
            }
            catch (RedirectMainException)
            {
                NavigationService.Navigate(typeof(MainPage));
            }
        }
        /// <summary>
        /// When navigated to this page, get the given house details
        /// </summary>
        /// <param name="parameter">url</param>
        /// <param name="mode"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            try
            {
                var houseUrl = (String)parameter;
                var service  = new ThroneService();
                House = await service.GetHouseAsync(houseUrl);

                CurrentLord = await service.GetCharacterAsync(House.CurrentLord);

                Heir = await service.GetCharacterAsync(House.Heir);

                Overlord = await service.GetHouseAsync(House.Overlord);

                Founder = await service.GetCharacterAsync(House.Founder);

                if (House.CadetBranches.Length != 0)
                {
                    Cadets.Clear();
                    foreach (String url in House.CadetBranches)
                    {
                        House newHouse = await service.GetHouseAsync(url);

                        Cadets.Add(newHouse);
                    }
                }

                if (House.SwornMembers.Length != 0)
                {
                    Sworns.Clear();
                    foreach (String url in House.SwornMembers)
                    {
                        Character newGuy = await service.GetCharacterAsync(url);

                        Sworns.Add(newGuy);
                    }
                }

                await base.OnNavigatedToAsync(parameter, mode, state);
            }
            catch (RedirectMainException)
            {
                NavigationService.Navigate(typeof(MainPage));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Request the url predicted books list, then add to the list property,
        /// if no internet connection redirect to mainpage
        /// </summary>
        /// <param name="url"></param>
        private async void SetBooksList(String url)
        {
            try
            {
                var service = new ThroneService();
                PagedResponse <List <Book> > obj = await service.GetBooksAsync(url);

                if (obj.result != null)
                {
                    List <Book> books = obj.result;
                    foreach (Book item in books)
                    {
                        Books.Add(item);
                    }
                }
            }
            catch (RedirectMainException)
            {
                NavigationService.Navigate(typeof(MainPage));
            }
        }
Beispiel #4
0
        /// <summary>
        /// Set the characterlist, which get from api request, with some error handling
        /// </summary>
        /// <param name="url"></param>
        private async void SetCharactersList(String url)
        {
            try
            {
                var service = new ThroneService();
                PagedResponse <List <Character> > obj = await service.GetCharactersAsync(url);

                if (obj.result != null)
                {
                    List <Character> characters = obj.result;
                    foreach (Character item in characters)
                    {
                        Characters.Add(item);
                    }
                }

                Buttons = obj.links;
            }
            catch (RedirectMainException)
            {
                NavigationService.Navigate(typeof(MainPage));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Set the list with houses from the response
        /// </summary>
        /// <param name="url"></param>
        private async void SetHousesList(String url)
        {
            try
            {
                var service = new ThroneService();
                PagedResponse <List <House> > obj = await service.GetHousesAsync(url);

                if (obj.result != null)
                {
                    List <House> houses = obj.result;
                    foreach (House item in houses)
                    {
                        Houses.Add(item);
                    }
                }

                Buttons = obj.links;
            }
            catch (RedirectMainException)
            {
                NavigationService.Navigate(typeof(MainPage));
            }
        }
        /// <summary>
        /// When navigated to the page, gets the book details via api request, and then some url-base data requested too
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="mode"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            try
            {
                var bookUrl = (string)parameter;
                var service = new ThroneService();
                Book = await service.GetBookAsync(bookUrl);

                if (Book.PovCharacters.Length != 0)
                {
                    PovCharacters.Clear();
                    foreach (String url in Book.PovCharacters)
                    {
                        Character newCharacter = await service.GetCharacterAsync(url);

                        PovCharacters.Add(newCharacter);
                    }
                }

                if (Book.Characters.Length != 0)
                {
                    Characters.Clear();
                    foreach (String url in Book.Characters)
                    {
                        Character newCharacter = await service.GetCharacterAsync(url);

                        Characters.Add(newCharacter);
                    }
                }

                await base.OnNavigatedToAsync(parameter, mode, state);
            }
            catch (RedirectMainException)
            {
                NavigationService.Navigate(typeof(MainPage));
            }
        }