Exemplo n.º 1
0
        private static void CreateVideos(VODContext dbContext)
        {
            Guid movieId = dbContext.Kinds
                           .Where(t => t.Name == "Movie")
                           .FirstOrDefault()
                           .Id;

            Guid seriesId = dbContext.Kinds
                            .Where(t => t.Name == "Series")
                            .FirstOrDefault()
                            .Id;

            #region Genres Identifiers

            Guid dramaId = dbContext.Genres
                           .Where(g => g.Name == "Drama")
                           .FirstOrDefault()
                           .Id;

            Guid comedyId = dbContext.Genres
                            .Where(g => g.Name == "Comedy")
                            .FirstOrDefault()
                            .Id;

            Guid thrillerId = dbContext.Genres
                              .Where(g => g.Name == "Thriller")
                              .FirstOrDefault()
                              .Id;

            Guid romanceId = dbContext.Genres
                             .Where(g => g.Name == "Romance")
                             .FirstOrDefault()
                             .Id;

            Guid actionId = dbContext.Genres
                            .Where(g => g.Name == "Action")
                            .FirstOrDefault()
                            .Id;

            Guid horrorId = dbContext.Genres
                            .Where(g => g.Name == "Horror")
                            .FirstOrDefault()
                            .Id;

            Guid crimeId = dbContext.Genres
                           .Where(g => g.Name == "Crime")
                           .FirstOrDefault()
                           .Id;

            Guid adventureId = dbContext.Genres
                               .Where(g => g.Name == "Adventure")
                               .FirstOrDefault()
                               .Id;

            Guid mysteryId = dbContext.Genres
                             .Where(g => g.Name == "Mystery")
                             .FirstOrDefault()
                             .Id;

            Guid animationId = dbContext.Genres
                               .Where(g => g.Name == "Animation")
                               .FirstOrDefault()
                               .Id;

            Guid sciFiId = dbContext.Genres
                           .Where(g => g.Name == "Sci-Fi")
                           .FirstOrDefault()
                           .Id;

            Guid[] genresId = new Guid[11];
            genresId[0]  = dramaId;
            genresId[1]  = comedyId;
            genresId[2]  = thrillerId;
            genresId[3]  = romanceId;
            genresId[4]  = actionId;
            genresId[5]  = horrorId;
            genresId[6]  = crimeId;
            genresId[7]  = adventureId;
            genresId[8]  = mysteryId;
            genresId[9]  = animationId;
            genresId[10] = sciFiId;

            #endregion
#if DEBUG
            DateTime     now       = DateTime.Now;
            Random       rand      = new Random();
            List <Video> videoList = new List <Video>();

            #region Description

            string desc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
                          "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
                          "A diam maecenas sed enim. Sollicitudin ac orci phasellus egestas tellus " +
                          "rutrum tellus pellentesque. Pellentesque sit amet porttitor eget dolor " +
                          "morbi non arcu. Aliquet nibh praesent tristique magna sit amet purus " +
                          "gravida. Aliquam faucibus purus in massa tempor. Scelerisque purus " +
                          "semper eget duis at tellus. In iaculis nunc sed augue lacus viverra " +
                          "vitae. Nulla at volutpat diam ut venenatis tellus in metus. Elit at " +
                          "imperdiet dui accumsan sit amet nulla.";

            #endregion

            #region Movie

            for (int i = 0; i < 90; i++)
            {
                int day   = rand.Next(1, 29);
                int month = rand.Next(1, 13);
                int year  = rand.Next(1990, 2021);

                Video movie = new Video()
                {
                    Title        = $"Title{i}",
                    AltTitle     = $"AltTitle{i}",
                    ReleaseYear  = new DateTime(year, month, day),
                    Duration     = (ushort)rand.Next(70, 200),
                    Description  = desc,
                    KindId       = movieId,
                    GenreId      = genresId[rand.Next(genresId.Length)],
                    CreationDate = now
                };

                videoList.Add(movie);
            }

            for (int i = 0; i < 10; i++)
            {
                int day   = rand.Next(1, 29);
                int month = rand.Next(1, 13);
                int year  = rand.Next(1990, 2021);

                Video movie = new Video()
                {
                    Title        = $"Title40",
                    AltTitle     = $"AltTitle40-{i}",
                    ReleaseYear  = new DateTime(year, month, day),
                    Duration     = (ushort)rand.Next(70, 200),
                    Description  = desc,
                    KindId       = movieId,
                    GenreId      = genresId[rand.Next(genresId.Length)],
                    CreationDate = now
                };

                videoList.Add(movie);
            }

            #endregion

            #region Series

            for (int i = 0; i < 90; i++)
            {
                int day   = rand.Next(1, 29);
                int month = rand.Next(1, 13);
                int year  = rand.Next(1990, 2021);

                Video series = new Video()
                {
                    Title        = $"Title{i}S",
                    AltTitle     = $"AltTitle{i}s{month}e{day}",
                    ReleaseYear  = new DateTime(year, month, day),
                    Duration     = (ushort)rand.Next(30, 61),
                    Description  = desc,
                    KindId       = seriesId,
                    GenreId      = genresId[rand.Next(genresId.Length)],
                    CreationDate = now,
                    Season       = (ushort)month,
                    Episode      = (ushort)day
                };

                videoList.Add(series);
            }

            for (int i = 0; i < 10; i++)
            {
                int    day     = rand.Next(1, 29);
                int    month   = rand.Next(1, 13);
                int    year    = rand.Next(1990, 2021);
                ushort season  = (ushort)(i + 1);
                ushort episode = (ushort)(day + 28);

                Video series = new Video()
                {
                    Title        = $"Title40S",
                    AltTitle     = $"AltTitle40s{season}e{episode}",
                    ReleaseYear  = new DateTime(year, month, day),
                    Duration     = (ushort)rand.Next(70, 200),
                    Description  = desc,
                    KindId       = seriesId,
                    GenreId      = genresId[rand.Next(genresId.Length)],
                    CreationDate = now,
                    Season       = season,
                    Episode      = episode
                };

                videoList.Add(series);
            }

            #endregion

            dbContext.Videos.AddRange(videoList);
#endif
            dbContext.SaveChanges();
        }
Exemplo n.º 2
0
        private static void CreateGenres(VODContext dbContext)
        {
            DateTime now = DateTime.Now;

            Genre gen0 = new Genre()
            {
                Name         = "Drama",
                CreationDate = now
            };

            Genre gen1 = new Genre()
            {
                Name         = "Comedy",
                CreationDate = now
            };

            Genre gen2 = new Genre()
            {
                Name         = "Thriller",
                CreationDate = now
            };

            Genre gen3 = new Genre()
            {
                Name         = "Romance",
                CreationDate = now
            };

            Genre gen4 = new Genre()
            {
                Name         = "Action",
                CreationDate = now
            };

            Genre gen5 = new Genre()
            {
                Name         = "Horror",
                CreationDate = now
            };

            Genre gen6 = new Genre()
            {
                Name         = "Crime",
                CreationDate = now
            };

            Genre gen7 = new Genre()
            {
                Name         = "Adventure",
                CreationDate = now
            };

            Genre gen8 = new Genre()
            {
                Name         = "Mystery",
                CreationDate = now
            };

            Genre gen9 = new Genre()
            {
                Name         = "Animation",
                CreationDate = now
            };

            Genre gen10 = new Genre()
            {
                Name         = "Sci-Fi",
                CreationDate = now
            };

            dbContext.Genres.AddRange(gen0, gen1, gen2, gen3, gen4, gen5, gen6, gen7,
                                      gen8, gen9, gen10);

            dbContext.SaveChanges();
        }