private async Task ProcessGenre(XElement genreElement, Action<Genre> genreAvailableCallback) { string titleResponse; string titleListingUrl = string.Format( TITLE_URL_FORMAT, genreElement.Element(NetflixXmlParser.AtomNodeNames.Id).Value); using (var titleClient = new HttpClient()) { titleClient.MaxResponseContentBufferSize = int.MaxValue; titleResponse = await titleClient.GetStringAsync(titleListingUrl); } var titleDoc = XDocument.Parse(titleResponse); var titleObjects = titleDoc.Descendants(NetflixXmlParser.AtomNodeNames.Entry).Select(e => NetflixXmlParser.ParseTitle(e)); var genre = new Genre { Name = genreElement.Element(NetflixXmlParser.AtomNodeNames.Title).Value, Titles = new ObservableCollection<Title>() }; foreach (var title in titleObjects) genre.Titles.Add(title); CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, (() => genreAvailableCallback(genre))); }
public void RaiseViewGenre(Genre genre) { if (ViewGenre != null) ViewGenre(this, new ViewGenreEventArgs(genre)); }
public ViewGenreEventArgs(Genre genre) { Genre = genre; }
private Genre GetGenre(Genre g) { var genre = _entities.Genres.Where(o => o.Code == g.Code).FirstOrDefault(); if (genre == null) { genre = new Genre { Name = g.Name, Code = g.Code, Rated = 0 }; _entities.AddToGenres(genre); _entities.SaveChanges(); } return genre; }