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); }
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); }