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)); } }
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)); } }