コード例 #1
0
ファイル: Program.cs プロジェクト: mrjeanjoseph/Deliverables
        static List <string> SearchByTitle(string userInput)
        {
            Console.WriteLine("Here is your movie. Enjoy! ");
            using (var context = new MovieDBContext())
            {
                var movie = context.Movies.Where(m => m.Title == userInput).ToList();

                List <string> result = new List <string>();
                Console.WriteLine(string.Format("\t{0,-25}{1,-15}{2,-15}", "Title", "Genre", "Runtime"));
                foreach (var movies in movie)
                {
                    string formattedResult = string.Format("\t{0,-25}{1,-15}{2,-15}", movies.Title, movies.Genre, movies.Runtime);
                    result.Add(formattedResult);
                }
                return(result);
            };
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mrjeanjoseph/Deliverables
        static List <string> SearchByGenre(string userInput)
        {
            using (var context = new MovieDBContext())
            {
                Console.WriteLine($"Here are a list of { userInput } movies.\nPlease wait...,");
                var movie = context.Movies.Where(m => m.Genre == userInput).ToList();

                List <string> result = new List <string>();
                Console.WriteLine(string.Format("\t{0,-25}{1,-25}", "Title", "Runtime"));
                foreach (var movies in movie)
                {
                    if (movies.Genre == "")
                    {
                        Console.WriteLine("I made it here");
                    }
                    string formattedResult = string.Format("\t{0,-25}{1,-25}", movies.Title, movies.Runtime);
                    result.Add(formattedResult);
                }
                return(result);
            };
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: mrjeanjoseph/Deliverables
 static void DisplayMenu(string choice)
 {
     using (var context = new MovieDBContext())
     {
         int count = 4;
         foreach (var movieList in context.Movies)
         {
             count++;
             if (choice == "title")
             {
                 string result = string.Format("{0,-5}{1,-25}{2,-15}{3, -15}", movieList.Id, movieList.Title, movieList.Genre, movieList.Runtime);
                 Console.WriteLine(result);
             }
             else if (choice == "genre")
             {
                 string result = string.Format("{0,-5}{1,-15}{2,-25}{3, -15}", movieList.Id, movieList.Genre, movieList.Title, movieList.Runtime);
                 Console.WriteLine(result);
             }
         }
         WriteAt("", 0, count + 4);
     };
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: mrjeanjoseph/Deliverables
 static void PopulateMovies()
 {
     using (var context = new MovieDBContext())
     {
         //Creating the constructor enabled the option to create multiple new movies at once.
         List <Movie> movieList = new List <Movie>()
         {
             new Movie("Men in Tights", "Comedy", 143.9),
             new Movie("Olympus Has Fallen", "Action", 141.8),
             new Movie("Law of Abiding Citizen", "Action", 163.15),
             new Movie("Blood and Bone", "Action", 128.15),
             new Movie("Hangover", "Comedy", 153.15),
             new Movie("Bruno", "Comedy", 153.15),
         };
         foreach (Movie m in movieList)
         {
             context.Movies.Add(m);
             Console.WriteLine($"{m.Title} has been saved!");
             context.SaveChanges();
         }
     };
 }