private static Show CreateShow(string name, int theTvDbId, Network network, Genre genre, Actor actor, User user) { return new Show { Name = name, TheTvDbId = theTvDbId, Network = network, ShowsGenres = { new ShowsGenres(genre) }, ShowsActors = { new ShowsActors { Actor = actor } }, ShowsUsers = { new ShowsUsers { User = user } }, Episodes = { new Episode { Title = "Title" } } }; }
private static async Task SeedGenresAsync(TrackTvDbContext context, IEnumerable<Show> shows = null) { if (shows == null) { var network = new Network("bbc"); var genre = new Genre("action"); var user = new User { Username = "******" }; var actor = new Actor { Name = "Cat" }; shows = new[] { CreateShow("Show1", 1000, network, genre, actor, user), CreateShow("Show2", 1001, network, genre, actor, user), CreateShow("Show3", 1002, network, genre, actor, user), CreateShow("Show4", 1003, network, genre, actor, user), CreateShow("Show5", 1004, network, genre, actor, user) }; } context.Shows.AddRange(shows); await context.SaveChangesAsync(); }
public bool HasGenre(Genre genre) { return this.ShowsGenres.Any(x => (x.Genre == genre) || ((x.GenreId != default(int)) && (x.GenreId == genre.Id))); }