public static void ImportMovie(MovieDTO movieDto) { string movieName = movieDto.Name; InputDataValidator.ValidateStringMaxLength(movieName, Constants.MaxMovieNameLength); float?rating = movieDto.Rating; InputDataValidator.ValidateFloatInRange(rating, Constants.MinRatingValue, Constants.MaxRatingValue); int releaseYear = movieDto.ReleaseYear; MovieValidator.ValidateMovieDoesNotExist(movieName, releaseYear); List <string> categories = movieDto.Categories.Select(c => c.Name).ToList(); CategoryValidator.CheckCategoriesExist(categories); string directorName = movieDto.DirectorName; int length = movieDto.Length; AgeRestriction ageRestriction = (AgeRestriction)Enum.Parse(typeof(AgeRestriction), movieDto.AgeRestriction); string synopsis = movieDto.Synopsis; string releaseCountry = movieDto.ReleaseCountry; byte[] image = movieDto.Image; MovieService.AddMovie(movieName, rating, length, directorName, releaseYear, ageRestriction, synopsis, releaseCountry, image); MovieImportService.AddCategoriesToMovie(movieName, releaseYear, categories); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.MoviesAddedSuccess, movieName)); }
private static void ImportAuditorium(AuditoriumDTO auditoriumDto) { string cinemaName = auditoriumDto.CinemaName; InputDataValidator.ValidateStringMaxLength(cinemaName, Constants.MaxCinemaNameLength); string townName = auditoriumDto.CinemaTownName; TownValidator.CheckTownExisting(townName); int townId = TownService.GetTownId(townName); int cinemaId = CinemaService.GetCinemaId(cinemaName, townId); CinemaValidator.CheckCinemaExisting(cinemaName, townId); byte number = auditoriumDto.Number; AuditoriumValidator.ValidateAuditoriumDoesNotExist(number, cinemaId, cinemaName); AuditoriumService.AddAuditorium(number, cinemaId); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.AuditoriumAddedSuccess, number, cinemaName, townName)); }
public static void ImportTown(TownDTO townDto) { string townName = townDto.Name; InputDataValidator.ValidateStringMaxLength(townName, Constants.MaxTownNameLength); TownValidator.ValidateTownDoesNotExist(townName); TownService.AddTown(townName); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.TownAddedSuccess, townName)); }
public static void ImportCategory(CategoryDTО categoryDtо) { string categoryName = categoryDtо.Name; InputDataValidator.ValidateStringMaxLength(categoryName, Constants.MaxCategoryNameLength); CategoryValidator.ValidateCategoryDoesNotExist(categoryName); CategoryService.AddCategory(categoryName); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.CategoryAddedSuccess, categoryName)); }
private void ImportCinema(CinemaDto cinemaDto) { string townName = cinemaDto.TownName; InputDataValidator.ValidateStringMaxLength(townName, Constants.MaxTownNameLength); string cinemaName = cinemaDto.Name; InputDataValidator.ValidateStringMaxLength(cinemaName, Constants.MaxCinemaNameLength); townService.AddTownIfNotExisting(townName); int townId = townService.GetTownId(townName); cinemaValidator.ValidateCinemaDoesNotExist(cinemaName, townId); cinemaService.AddCinema(cinemaName, townId); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.CinemaAddedSuccess, cinemaName)); }
public void ImportActor(ActorDto actorDto) { string actorName = actorDto.Name; InputDataValidator.ValidateStringMaxLength(actorName, Constants.MaxActorNameLength); actorValidator.ValidateActorDoesntExist(actorName); float?actorRating = actorDto.Rating; InputDataValidator.ValidateFloatInRange(actorRating, Constants.MinRatingValue, Constants.MaxRatingValue); List <ActorMovieDto> movies = actorDto.Movies; movieValidator.CheckMoviesExist(movies); actorService.AddActor(actorName, actorRating); this.AddMoviesToActor(actorName, movies); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.ActorAddedSuccess, actorName)); }