Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var dbContext = new VidzyDbContext();

            dbContext.AddVideo("1123", DateTime.Now, 1, Classification.Platinum);
            dbContext.AddVideo("12323", DateTime.Now, 2, Classification.Gold);
            dbContext.AddVideo("123", DateTime.Now, 4, Classification.Silver);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var DbContext = new VidzyDbContext();

            DbContext.AddVideo("Zurassic World", new DateTime(2016, 9, 23), 1, 1);
            DbContext.AddVideo("The Lord of The Rings", new DateTime(2001, 6, 12), 4, 2);
            DbContext.AddVideo("The Hateful Eight", new DateTime(2007, 8, 9), 4, 3);
            DbContext.SaveChanges();
        }
 private static void AddMovie()
 {
     using (var dbContext = new VidzyDbContext())
     {
         dbContext.AddVideo("Die Hard 3", new DateTime(1990, 01, 01), "Action", Classification.Gold);
         dbContext.AddVideo("Harry Potter", new DateTime(1990, 01, 01), "Action", Classification.Platinum);
         dbContext.AddVideo("The Avengers: End Game", new DateTime(2002, 01, 01), "Action", Classification.Silver);
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var dbContext = new VidzyDbContext();

            dbContext.Videos.Add(new Video()
            {
                Name = "Pendulum", ReleaseDate = DateTime.Now
            });
            dbContext.SaveChanges();

            foreach (var video in dbContext.Videos)
            {
                Console.WriteLine($"{video.Name} - {video.ReleaseDate}");
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var dbContext = new VidzyDbContext();

            var genres = dbContext.Genres.ToList();

            var video = new Video
            {
                Name        = "Teste 2",
                ReleaseDate = DateTime.Parse("12/23/2015", CultureInfo.InvariantCulture),
                Genre       = new Genre()
                {
                    Name = "Comedy"
                },
                Classification = Classification.Gold
            };

            var result = dbContext.AddVideo(video.Name, video.ReleaseDate, video.Genre.Name, (byte)video.Classification);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            VidzyDbContext context = new VidzyDbContext();

            context.AddVideo("film_47", DateTime.Now, "Horror", (byte)Classification.Platinum);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var vidzyContext = new VidzyDbContext();

            vidzyContext.AddVideo("Half Baked", new DateTime(1998, 1, 1), "Comedy", (byte)Classification.Gold);
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            var dbContext = new VidzyDbContext();

            dbContext.AddVideo("Video 5", DateTime.Now, "Comedy", Classification.Gold);
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            VidzyDbContext context = new VidzyDbContext();

            //Action movies sorted by name
            //var actionMovies = context.Videos.Where(v => v.Genre.Name == "Action");
            //foreach (var m in actionMovies)
            //    Console.WriteLine(m.Name);

            //Gold drama movies sorted by release date (newest first)
            //var dramaMovies = context.Videos.Where(v => v.Genre.Name == "Drama").Where(v => v.Classification == Classification.Gold).OrderByDescending(v => v.ReleaseDate);
            //foreach (var m in dramaMovies)
            //    Console.WriteLine(m.Name);

            //All movies projected into an anonymous type with two properties: MovieName and Genre
            //var project = context.Videos.Select(v =>
            //    new {
            //        MovieName = v.Name,
            //        Genre = v.Genre.Name
            //     });
            //foreach(var v in project)
            //    Console.WriteLine(v.MovieName + "\t" + v.Genre);

            //All movies grouped by their classification
            //var groupBy = context.Videos.GroupBy(v => v.Classification);
            //foreach(var grounp in groupBy)
            //{
            //    Console.WriteLine(grounp.Key);
            //    foreach (var g in grounp)
            //        Console.WriteLine(g.Name);
            //}

            //List of classifications sorted alphabetically and count of videos in them
            //var sort = context.Videos.GroupBy(v => v.Classification).Select(v =>
            //    new
            //    {
            //        Classification = v.Key.ToString(),
            //        Count = v.Count()
            //    }) ;
            //foreach (var s in sort)
            //    Console.WriteLine(s.ToString());

            //List of genres and number of videos they include, sorted by the number of videos
            var genres = context.Genres
                         .GroupJoin(context.Videos, g => g.Id, v => v.GenreId, (genre, videos) => new
            {
                Name        = genre.Name,
                VideosCount = videos.Count()
            })
                         .OrderByDescending(g => g.VideosCount);

            Console.WriteLine();
            Console.WriteLine("GENRES AND NUMBER OF VIDEOS IN THEM");
            foreach (var g in genres)
            {
                Console.WriteLine("{0} ({1})", g.Name, g.VideosCount);
            }



            Console.ReadLine();
        }