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);
        }
Exemplo n.º 2
0
        //Függvény, ami meghívódik, ha a HouseDetailsPage lesz az aktív View
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            //Egy új service indítása, a paraméterben kapott ház adatainak betöltése
            string     url     = (string)parameter;
            GoTService service = new GoTService();

            House = await service.GetAsync <House>(new Uri(url));

            if (House.Titles[0] != "")
            {
                string titles = "";
                foreach (var title in House.Titles)
                {
                    titles += title + ", ";
                }
                Titles = DeleteLastComa(titles);
            }

            if (House.Seats[0] != "")
            {
                string seats = "";
                foreach (var seat in House.Seats)
                {
                    seats += seat + ", ";
                }
                Seats = DeleteLastComa(seats);
            }

            if (House.CurrentLord != "")
            {
                var lord = await service.GetAsync <Character>(new Uri(House.CurrentLord));

                CurrentLord = lord.Name;
            }

            if (House.Heir != "")
            {
                var heir = await service.GetAsync <Character>(new Uri(House.Heir));

                Heir = heir.Name;
            }

            if (House.Overlord != "")
            {
                var ol = await service.GetAsync <House>(new Uri(House.Overlord));

                Overlord = ol.Name;
            }

            if (House.Founder != "")
            {
                var fr = await service.GetAsync <Character>(new Uri(House.Founder));

                Founder = fr.Name;
            }

            if (House.AncestralWeapons[0] != "")
            {
                string aw = "";
                foreach (var weapon in House.AncestralWeapons)
                {
                    aw += weapon + ", ";
                }
                AncestralWeapons = DeleteLastComa(aw);
            }

            if (House.CadetBranches.Length > 0)
            {
                foreach (var branchURL in House.CadetBranches)
                {
                    var house = await service.GetAsync <House>(new Uri(branchURL));

                    CadetBranches.Add(house);
                }
            }
            else
            {
                CadetBranches.Add(new House {
                    Name = "N/A"
                });
            }

            if (House.SwornMembers.Length > 0)
            {
                foreach (var charURL in House.SwornMembers)
                {
                    var character = await service.GetAsync <Character>(new Uri(charURL));

                    SwornMembers.Add(character);
                }
            }
            else
            {
                SwornMembers.Add(new Character {
                    Name = "N/A"
                });
            }

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