private object GetExamples(NamingConfigResource config) { if (config.Id == 0) { config = GetNamingConfig(); } var nameSpec = config.ToModel(); var sampleResource = new NamingExampleResource(); var singleEpisodeSampleResult = _filenameSampleService.GetStandardSample(nameSpec); var multiEpisodeSampleResult = _filenameSampleService.GetMultiEpisodeSample(nameSpec); var dailyEpisodeSampleResult = _filenameSampleService.GetDailySample(nameSpec); var animeEpisodeSampleResult = _filenameSampleService.GetAnimeSample(nameSpec); var animeMultiEpisodeSampleResult = _filenameSampleService.GetAnimeMultiEpisodeSample(nameSpec); sampleResource.SingleEpisodeExample = _filenameValidationService.ValidateStandardFilename(singleEpisodeSampleResult) != null ? null : singleEpisodeSampleResult.FileName; sampleResource.MultiEpisodeExample = _filenameValidationService.ValidateStandardFilename(multiEpisodeSampleResult) != null ? null : multiEpisodeSampleResult.FileName; sampleResource.DailyEpisodeExample = _filenameValidationService.ValidateDailyFilename(dailyEpisodeSampleResult) != null ? null : dailyEpisodeSampleResult.FileName; sampleResource.AnimeEpisodeExample = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult) != null ? null : animeEpisodeSampleResult.FileName; sampleResource.AnimeMultiEpisodeExample = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult) != null ? null : animeMultiEpisodeSampleResult.FileName; sampleResource.SeriesFolderExample = nameSpec.SeriesFolderFormat.IsNullOrWhiteSpace() ? null : _filenameSampleService.GetSeriesFolderSample(nameSpec); sampleResource.SeasonFolderExample = nameSpec.SeasonFolderFormat.IsNullOrWhiteSpace() ? null : _filenameSampleService.GetSeasonFolderSample(nameSpec); sampleResource.SpecialsFolderExample = nameSpec.SpecialsFolderFormat.IsNullOrWhiteSpace() ? null : _filenameSampleService.GetSpecialsFolderSample(nameSpec); return(sampleResource); }
private void ValidateFormatResult(NamingConfig nameSpec) { var singleEpisodeSampleResult = _filenameSampleService.GetStandardSample(nameSpec); var multiEpisodeSampleResult = _filenameSampleService.GetMultiEpisodeSample(nameSpec); var dailyEpisodeSampleResult = _filenameSampleService.GetDailySample(nameSpec); var animeEpisodeSampleResult = _filenameSampleService.GetAnimeSample(nameSpec); var animeMultiEpisodeSampleResult = _filenameSampleService.GetAnimeMultiEpisodeSample(nameSpec); var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec); var singleEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(singleEpisodeSampleResult); var multiEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(multiEpisodeSampleResult); var dailyEpisodeValidationResult = _filenameValidationService.ValidateDailyFilename(dailyEpisodeSampleResult); var animeEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult); var animeMultiEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult); //var standardMovieValidationResult = _filenameValidationService.ValidateMovieFilename(movieSampleResult); For now, let's hope the user is not stupid enough :/ var validationFailures = new List <ValidationFailure>(); //validationFailures.AddIfNotNull(singleEpisodeValidationResult); //validationFailures.AddIfNotNull(multiEpisodeValidationResult); //validationFailures.AddIfNotNull(dailyEpisodeValidationResult); //validationFailures.AddIfNotNull(animeEpisodeValidationResult); //validationFailures.AddIfNotNull(animeMultiEpisodeValidationResult); //validationFailures.AddIfNotNull(standardMovieValidationResult); if (validationFailures.Any()) { throw new ValidationException(validationFailures.DistinctBy(v => v.PropertyName).ToArray()); } }
private JsonResponse <NamingSampleResource> GetExamples(NamingConfigResource config) { var nameSpec = config.InjectTo <NamingConfig>(); var sampleResource = new NamingSampleResource(); var singleEpisodeSampleResult = _filenameSampleService.GetStandardSample(nameSpec); var multiEpisodeSampleResult = _filenameSampleService.GetMultiEpisodeSample(nameSpec); var dailyEpisodeSampleResult = _filenameSampleService.GetDailySample(nameSpec); var animeEpisodeSampleResult = _filenameSampleService.GetAnimeSample(nameSpec); var animeMultiEpisodeSampleResult = _filenameSampleService.GetAnimeMultiEpisodeSample(nameSpec); sampleResource.SingleEpisodeExample = _filenameValidationService.ValidateStandardFilename(singleEpisodeSampleResult) != null ? "Invalid format" : singleEpisodeSampleResult.FileName; sampleResource.MultiEpisodeExample = _filenameValidationService.ValidateStandardFilename(multiEpisodeSampleResult) != null ? "Invalid format" : multiEpisodeSampleResult.FileName; sampleResource.DailyEpisodeExample = _filenameValidationService.ValidateDailyFilename(dailyEpisodeSampleResult) != null ? "Invalid format" : dailyEpisodeSampleResult.FileName; sampleResource.AnimeEpisodeExample = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult) != null ? "Invalid format" : animeEpisodeSampleResult.FileName; sampleResource.AnimeMultiEpisodeExample = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult) != null ? "Invalid format" : animeMultiEpisodeSampleResult.FileName; sampleResource.SeriesFolderExample = nameSpec.SeriesFolderFormat.IsNullOrWhiteSpace() ? "Invalid format" : _filenameSampleService.GetSeriesFolderSample(nameSpec); sampleResource.SeasonFolderExample = nameSpec.SeasonFolderFormat.IsNullOrWhiteSpace() ? "Invalid format" : _filenameSampleService.GetSeasonFolderSample(nameSpec); return(sampleResource.AsResponse()); }