예제 #1
0
 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"
             }
         }
     };
 }
예제 #2
0
        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();
        }
예제 #3
0
파일: Show.cs 프로젝트: HristoKolev/TrackTV
 public bool HasGenre(Genre genre)
 {
     return this.ShowsGenres.Any(x => (x.Genre == genre) || ((x.GenreId != default(int)) && (x.GenreId == genre.Id)));
 }