Ejemplo n.º 1
0
        /// <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));
            }
        }