Beispiel #1
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            //gets the requested character
            string url    = (string)parameter;
            var    client = new GoTService();

            CurrentCharacter = await client.GetCharacterByUrlAsync(url);

            //First we need to check if the father data exists, if yes, the app makes a new call to the API to get the father's name
            if (CurrentCharacter.Father != "")
            {
                Character father = await client.GetCharacterByUrlAsync(CurrentCharacter.Father);

                FatherName = father.Name;
            }

            if (CurrentCharacter.Mother != "")
            {
                Character mother = await client.GetCharacterByUrlAsync(CurrentCharacter.Mother);

                MotherName = mother.Name;
            }

            if (CurrentCharacter.Spouse != "")
            {
                Character spouse = await client.GetCharacterByUrlAsync(CurrentCharacter.Spouse);

                SpouseName = spouse.Name;
            }

            foreach (var house in CurrentCharacter.Allegiances)
            {
                House h = await client.GetHouseByUrlAsync(house);

                //types are needed for navigation
                _allegiances.Add(h);
                //name is shown on the UI
                Allegiances.Add(h.Name);
            }

            foreach (var bookName in CurrentCharacter.Books)
            {
                Book b = await client.GetBookByUrlAsync(bookName);

                _books.Add(b);
                BookNames.Add(b.Name);
            }

            foreach (var povBookName in CurrentCharacter.PovBooks)
            {
                Book b = await client.GetBookByUrlAsync(povBookName);

                _povBooks.Add(b);
                PovBookNames.Add(b.Name);
            }

            await base.OnNavigatedToAsync(parameter, mode, state);
        }
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            string url    = (string)parameter;
            var    client = new GoTService();

            CurrentHouse = await client.GetHouseByUrlAsync(url);

            //Only request the name of the current lord if their Uri was given by the web API
            if (CurrentHouse.CurrentLord != "")
            {
                Character lord = await client.GetCharacterByUrlAsync(CurrentHouse.CurrentLord);

                CurrentLord = lord.Name;
            }

            //Only request the name of the heir if their Uri was given by the web API

            if (CurrentHouse.Heir != "")
            {
                Character heir = await client.GetCharacterByUrlAsync(CurrentHouse.Heir);

                Heir = heir.Name;
            }

            //Only request the name of the founder if their Uri was given by the web API
            if (CurrentHouse.Founder != "")
            {
                Character founder = await client.GetCharacterByUrlAsync(CurrentHouse.Founder);

                Founder = founder.Name;
            }

            foreach (var member in CurrentHouse.SwornMembers)
            {
                Character c = await client.GetCharacterByUrlAsync(member);

                //saves the character object, needed for navigation
                _members.Add(c);
                //saves the character's name separately, needed so it can be shown on the UI
                SwornMembers.Add(c.Name);
            }

            foreach (var house in CurrentHouse.CadetBranches)
            {
                House h = await client.GetHouseByUrlAsync(house);

                _branches.Add(h);
                CadetBranches.Add(h.Name);
            }

            await base.OnNavigatedToAsync(parameter, mode, state);
        }
Beispiel #3
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            //gets the book from the passed parameter
            string url    = (string)parameter;
            var    client = new GoTService();

            CurrentBook = await client.GetBookByUrlAsync(url);

            foreach (var povCharacter in CurrentBook.PovCharacters)
            {
                Character c = await client.GetCharacterByUrlAsync(povCharacter);

                //Saves the name field to a collection that is shown on the UI
                PovCharacterNames.Add(c.Name);
                //Saves the entire type, needed for navigation
                _povCharacters.Add(c);
            }

            //sets a specific limit, so the app wont get overwhelmed with too much data
            int limit = 20;
            int i     = 0;

            foreach (var character in CurrentBook.Characters)
            {
                if (i >= limit)
                {
                    break;
                }

                Character c = await client.GetCharacterByUrlAsync(character);

                if (c.Name != "")
                {
                    //Saves the name field to a collection that is shown on the UI
                    CharacterNames.Add(c.Name);
                    //Saves the entire type, needed for navigation
                    _characters.Add(c);
                }
                i++;
            }

            await base.OnNavigatedToAsync(parameter, mode, state);
        }