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