async Task <CPersonResult> GetPerson(int id) { string query_line = api_base_url + "person/" + id + "?api_key=" + api_key + "&language=en-US"; CPersonResult person = await GetFromJSON <CPersonResult>(query_line); return(person); }
private async void Search_Click(object sender, RoutedEventArgs e) { HideResults(); TextBox textbox = (TextBox)LogicalTreeHelper.FindLogicalNode(m_RootElement, "search_box"); SetStatus("searching..."); CPersonSearchResult search_results = await SearchActors(textbox.Text); if (search_results != null) { if (search_results.total_pages > 0) { SetStatus("processing results..."); string name = search_results.results[0].name; string url = await MakeProfileImageUrl(search_results.results[0].profile_path); byte[] image_data = await GetImageData(url); m_CurrentActor = new RemoteCatalogService.Actor(); string first_name = name; string last_name = ""; int space = name.IndexOf(" "); if (space != -1) { first_name = name.Substring(0, space).Trim(); last_name = name.Substring(space + 1).Trim(); } m_CurrentActor.FirstName = first_name; m_CurrentActor.LastName = last_name; m_CurrentActor.Image = image_data; // we now have portrait, name and an id... lets get more info on this person. CPersonResult person = await GetPerson(search_results.results[0].id); m_CurrentActor.Bio = person.biography; m_CurrentActor.Link = person.homepage; BitmapImage image = null; MemoryStream image_stream = null; if (image_data != null) { image_stream = new MemoryStream(image_data); image = LoadImageFromStream(image_stream); SetActorToUI(name, m_CurrentActor.Bio, image); image_stream.Close(); } } } SetStatus(""); }