static void Main(string[] args)
        {
            var context = new MovieContext();

            var adultMovies = context.Movies
                .OrderBy(m => m.Title)
                .ThenBy(m => m.Ratings.Count)
                .Where(m => m.AgeRestriction == AgeRestriction.Adult)
                .Select(m => new
                {
                    title = m.Title,
                    ratingsGiven = m.Ratings.Count
                });

            var json = new JavaScriptSerializer().Serialize(adultMovies);

            File.WriteAllText(@"adult-movies.json", json);
        }
        static void Main(string[] args)
        {
            var context = new MovieContext();

            var topTenFavoriteTeenMovies = context.Movies
                .Where(m => m.AgeRestriction == AgeRestriction.Teen)
                .OrderByDescending(m => m.Users.Count)
                .ThenBy(m => m.Title)
                .Select(m => new
                {
                    isbn = m.Isbn,
                    title = m.Title,
                    favouritedBy = m.Users.Select(u => u.Username)
                });

            var json = new JavaScriptSerializer().Serialize(topTenFavoriteTeenMovies);

            File.WriteAllText(@"top-10-favourite-movies.json", json);
        }
        static void Main(string[] args)
        {
            var context = new MovieContext();

            var ratedMoviesByUser = context.Users
                .Where(u => u.Username == "jmeyery")
                .Select(u => new
                {
                    username = u.Username,
                    ratedMovies = u.Ratings.Where(r => r.UserId == u.Id)
                        .Select(r => new
                        {
                            title = r.Movie.Title,
                            userRating = r.Stars,
                            averageRating = r.Movie.Ratings.Select(mr => mr.Stars).Average()
                        })
                        .OrderBy(m => m.title)
                });

            var json = new JavaScriptSerializer().Serialize(ratedMoviesByUser);

            File.WriteAllText(@"rated-movies-by-jmeyery.json", json);
        }