Ejemplo n.º 1
0
        private static void UpdateGenre()
        {
            WriteLine("Which genre would you like to update? (ID)");
            var genre = FindGenreById();

            if (genre != null)
            {
                WriteLine("You are updating the following genre:");
                WriteLine($"ID: {genre.Id} |Name: {genre.Name}");

                WriteLine("Name of genre: ");
                var name = ReadLine();

                WriteLine("You have inputted the following info:");
                WriteLine($"ID: {genre.Id} |Name: {name}");
                if (ExtraUI.ConfirmInfo())
                {
                    genre.Name = name;
                    bllFacade.GenreService.UpdateGenre(genre);
                    WriteLine("Genre has been updated");
                }
                else
                {
                    WriteLine("The genre was not updated");
                }
            }
        }
Ejemplo n.º 2
0
        private static void CreateVideo()
        {
            WriteLine("Genre: ");
            var genre = GenreExistCheck();


            WriteLine("Name: ");
            var name = ReadLine();

            WriteLine("You have inputted the following info:");
            WriteLine($"Genre: {genre.Name} |Name: {name}");

            if (ExtraUI.ConfirmInfo())
            {
                bllFacade.VideoService.CreateVideo(new VideoBO()
                {
                    Genre = genre.Name,
                    Name  = name
                });
                WriteLine("Video is now in information");
            }
            else
            {
                WriteLine("The video was not added");
            }
        }
Ejemplo n.º 3
0
        private static void CreateGenre()
        {
            WriteLine("Name of genre: ");
            var name = ReadLine();

            WriteLine("You have inputted the following info:");
            WriteLine($"Name: {name}");

            if (ExtraUI.ConfirmInfo())
            {
                if (bllFacade.GenreService.CreateGenre(new GenreBO()
                {
                    Name = name
                }))
                {
                    WriteLine("Genre is now in information");
                }
                else
                {
                    WriteLine("This genre already exist");
                }
            }
            else
            {
                WriteLine("The Genre was not added");
            }
        }
Ejemplo n.º 4
0
        private static GenreBO GenreExistCheck()
        {
            bool    foundGenre = false;
            string  str        = ReadLine();
            GenreBO genre      = null;

            while (!foundGenre)
            {
                genre = bllFacade.GenreService.GetGenreByName(str);
                if (genre != null)
                {
                    return(genre);
                }
                else
                {
                    WriteLine("The genre inputted was not found");
                    WriteLine($"Do you wish to create a genre named {str}");

                    if (ExtraUI.ConfirmInfo())
                    {
                        genre = new GenreBO {
                            Name = str
                        };
                        bllFacade.GenreService.CreateGenre(genre);
                        return(genre);
                    }
                    else
                    {
                    }
                }
                str = ReadLine();
            }
            return(null);
        }
Ejemplo n.º 5
0
        private static void UpdateVideo()
        {
            WriteLine("Which Video would you like to update? (ID)");
            var video = FindVideoById();

            if (video != null)
            {
                WriteLine("You are updating the following video:");
                WriteLine($"Genre: {video.Genre} |Name: {video.Name}");
                WriteLine("Genre: ");
                var genre = GenreExistCheck();

                WriteLine("Name: ");
                var name = ReadLine();

                WriteLine("You have inputted the following info:");
                WriteLine($"Genre: {genre.Name} |Name: {name}");
                if (ExtraUI.ConfirmInfo())
                {
                    video.Genre = genre.Name;
                    video.Name  = name;
                    bllFacade.VideoService.UpdateVideo(video);
                    WriteLine("Video has been updated");
                }
                else
                {
                    WriteLine("The video was not updated");
                }
            }
        }
Ejemplo n.º 6
0
        public static void VideoMenu()
        {
            #region Menu Items
            string[] menuItems =
            {
                "Add a video",
                "Add multiple videos",
                "List all videos",
                "Update a video",
                "Delete a video",
                "Search in all videos",
                "Back"
            };
            #endregion

            #region Menu Switch
            var selection = ExtraUI.ShowMenu(menuItems);
            while (selection != 7)
            {
                switch (selection)
                {
                case 1:
                    CreateVideo();
                    break;

                case 2:
                    CreateMultipleVideos();
                    break;

                case 3:
                    ListAllVideos();
                    break;

                case 4:
                    UpdateVideo();
                    break;

                case 5:
                    DeleteVideo();
                    break;

                case 6:
                    SearchVideos();
                    break;
                }
                WriteLine("Press Enter to go back to the menu");
                ReadLine();
                selection = ExtraUI.ShowMenu(menuItems);
            }
            #endregion
            WriteLine("Press Enter to return to the main menu");
            ReadLine();
        }
Ejemplo n.º 7
0
        public static void GenreMenu()
        {
            #region Menu Items
            string[] menuItems =
            {
                "Create a genre",
                "List all genres",
                "Change a genre",
                "Remove a genre",
                "Search in genres",
                "Back"
            };
            #endregion

            #region Menu Switch
            var selection = ExtraUI.ShowMenu(menuItems);
            while (selection != 6)
            {
                switch (selection)
                {
                case 1:
                    CreateGenre();
                    break;

                case 2:
                    ListAllGenres();
                    break;

                case 3:
                    UpdateGenre();
                    break;

                case 4:
                    RemoveGenre();
                    break;

                case 5:
                    SearchGenres();
                    break;
                }
                WriteLine("Press Enter to go back to the menu");
                ReadLine();
                selection = ExtraUI.ShowMenu(menuItems);
            }
            #endregion
            WriteLine("Press Enter to return to the main menu");
            ReadLine();
        }
Ejemplo n.º 8
0
        private static void CreateMultipleVideos()
        {
            WriteLine("How many videos do you wish to add?");
            int times;

            while (!int.TryParse(ReadLine(), out times))
            {
                WriteLine("Please input a number");
            }
            WriteLine("What is the genre for all of these videos?:");
            WriteLine("Genre: ");
            var            genre  = GenreExistCheck();
            List <VideoBO> videos = new List <VideoBO>();

            WriteLine("C to cancel and A to Accept enter all inputted info");
            bool save = true;

            for (int i = 0; i < times; i++)
            {
                WriteLine("Name: ");
                var name = ReadLine();
                if (name.ToLower().Equals("c"))
                {
                    save = false;
                    break;
                }
                else if (name.ToLower().Equals("a"))
                {
                    WriteLine("You have inputted the following info:");
                }
                WriteLine($"Genre: {genre.Name} |Name: {name}");
                if (ExtraUI.ConfirmInfo())
                {
                    videos.Add(new VideoBO {
                        Genre = genre.Name, Name = name
                    });
                }
                else
                {
                    WriteLine("The video was not added");
                    i--;
                }
            }
            if (save)
            {
                bllFacade.VideoService.CreateMultipleVideos(videos);
            }
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            //Fills the database with mockdata
            
            FillDatabaseWithGenres();
            FillDatabaseWithVideos();
            //This should be removed at the end of project
            #region Menu Items
            string[] menuItems =
            {
                "Genres",
                "Videos",
                "Exit"
            };
            #endregion

            #region Menu Switch
            var selection = ExtraUI.ShowMenu(menuItems);
            while (selection != 3)
            {
                switch (selection)
                {
                    case 1:
                        GenreUI.GenreMenu();
                        break;
                    case 2:
                        VideoUI.VideoMenu();
                        break;

                }
                selection = ExtraUI.ShowMenu(menuItems);


            }
            #endregion
            WriteLine("Press enter to close the program");
            ReadLine();

        }