/// <summary> /// Gets all registered reports /// </summary> /// <param name="categoryName">The category name</param> /// <param name="options">The globalization options (optional)</param> /// <returns>A collection of registered reports</returns> public IEnumerable <RegisteredReport> GetReportsByCategory ( string categoryName, GlobalizationOptions options = null ) { var category = _categoryRepository.GetCategory ( categoryName ); var reportNames = category.AssignedReports.Select ( a => a.ReportName ) .ToList(); var allReports = _reportRepository.GetAllReports(); var matchingReports = allReports.Where ( report => reportNames.Any ( name => name.Equals(report.Name, StringComparison.OrdinalIgnoreCase) ) ); matchingReports.Localize ( _translator, options ); return(matchingReports); }
/// <summary> /// Creates a single report sub category /// </summary> /// <param name="parentCategoryName">The parent category name</param> /// <param name="configuration">The category configuration</param> /// <returns>The category created</returns> public ReportCategory CreateSubCategory ( string parentCategoryName, ReportCategoryConfiguration configuration ) { Validate.IsNotEmpty(parentCategoryName); Validate.IsNotNull(configuration); var name = configuration.Name; var nameAvailable = _categoryRepository.IsNameAvailable ( name ); if (false == nameAvailable) { throw new InvalidOperationException ( $"The category name '{name}' is not available." ); } var parentCategory = _categoryRepository.GetCategory ( parentCategoryName ); var subCategory = parentCategory.CreateSubCategory ( configuration ); _categoryRepository.AddCategory(subCategory); _unitOfWork.SaveChanges(); return(subCategory); }