Beispiel #1
0
        public IEnumerable <string> Execute(IEnumerable <string> input)
        {
            var parameters = input.ToList();

            cinemaConsole.Clear();
            cinemaConsole.WriteLineMiddle("Type a user name | age:\n");

            try
            {
                var clientInput = cinemaConsole.ReadLineMiddle().Split('|');
                var userName    = clientInput[0];
                if (!int.TryParse(clientInput[1], out int userAge))
                {
                    throw new InvalidClientInputException("Age must be integer number");
                }
                Validations(userName);

                var movies = watchedMovieServices.GetWatchedMoviesByUserName(userName, userAge);

                pdfExporter.ExportUserWatchedMovies(movies, userName);
                cinemaConsole.HandleOperation("\nSuccessfully exported data to PDF");
                return(parameters.Skip(1));
            }
            catch (InvalidClientInputException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (EntityDoesntExistException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
        }
Beispiel #2
0
        public IEnumerable <string> Execute(IEnumerable <string> input)
        {
            var parameters = input.ToList();

            cinemaConsole.Clear();
            try
            {
                //Fill watchedMovies with data
                FillCollectionWithData();

                //Export watchedMovies by users in pdf file
                pdfExporter.ExportWatchedMoviesByUsers(watchedMovies);

                cinemaConsole.HandleOperation("\nSuccessfully exported data to PDF");
                return(parameters.Skip(1));
            }
            catch (EmptyEntityTableException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (iText.Kernel.PdfException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
        }
        public IEnumerable <string> Execute(IEnumerable <string> inputAsIEnumerable)
        {
            var parameters = inputAsIEnumerable.ToList();

            cinemaConsole.Clear();
            cinemaConsole.WriteLineMiddle("Format: Movie Name | Genre");
            try
            {
                var input = cinemaConsole.ReadLineMiddle().Split('|');
                Validations(input);

                var movieID = movieServices.GetID(input[0].TrimEnd().TrimStart());
                var genreID = genreServices.GetID(input[1].TrimEnd().TrimStart());

                movieGenreServices.AddNew(movieID, genreID);
                cinemaConsole.HandleOperation("\nSuccessfully added to database");
                return(parameters.Skip(1));
            }
            catch (InvalidClientInputException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (EntityDoesntExistException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (EntityAlreadyExistsException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
        }
Beispiel #4
0
        public IEnumerable <string> Execute(IEnumerable <string> input)
        {
            var parameters = input.ToList();

            cinemaConsole.Clear();
            cinemaConsole.WriteLineMiddle("Type a city name:\n");
            try
            {
                var cityName = cinemaConsole.ReadLineMiddle().TrimEnd().TrimStart();
                Validations(cityName);
                cityServices.AddNewCity(cityName);
                cinemaConsole.HandleOperation("\nSuccessfully added to database");
                return(parameters.Skip(1));
            }
            catch (InvalidClientInputException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (EntityAlreadyExistsException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
        }
        public IEnumerable <string> Execute(IEnumerable <string> input)
        {
            var parameters = input.ToList();

            cinemaConsole.Clear();
            cinemaConsole.WriteLineMiddle("Type a movie name:\n");

            try
            {
                string movieName = cinemaConsole.ReadLineMiddle().TrimEnd().TrimStart();
                Validations(movieName);
                movieServices.DeleteMovie(movieName);
                cinemaConsole.HandleOperation("\nSuccessfully deleted from database");
                return(parameters.Skip(1));
            }
            catch (InvalidClientInputException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (EntityDoesntExistException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
        }
Beispiel #6
0
        public IEnumerable <string> Execute(IEnumerable <string> inputAsIEnumerable)
        {
            var parameters = inputAsIEnumerable.ToList();

            cinemaConsole.Clear();
            cinemaConsole.WriteLineMiddle("Format: MovieName(50) | CityName(50) | OpenHour (Format: HH:MMh) | Date (Format: YYYY-MM-DD)", 0);

            try
            {
                var input = cinemaConsole.ReadLineMiddle(0).Split('|');
                Validations(input);

                var movieID    = movieServices.GetID(input[0].TrimEnd().TrimStart());
                var cityID     = cityServices.GetID(input[1].TrimEnd().TrimStart());
                var openHourID = openHourServices.GetID(input[2].TrimEnd().TrimStart());


                projectionsServices.Delete(cityID, movieID, openHourID);
                cinemaConsole.HandleOperation("\nSuccessfully deleted from database");
                return(parameters.Skip(1));
            }
            catch (InvalidClientInputException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (EntityDoesntExistException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
            catch (EntityAlreadyExistsException e)
            {
                cinemaConsole.HandleException(e.Message);
                return(parameters.Skip(1));
            }
        }