/// <summary> /// Creates campaign list excel configuration builder. /// </summary> /// <param name="builder">The builder.</param> private static ExcelConfigurationBuilder <CampaignReportModel> CreateExcelConfigurationBuilder() { var confBuilder = new ExcelConfigurationBuilder <CampaignReportModel>() .DefaultStyle(GamePlanReportStyles.DataCellStyle.Name) .HeaderStyle(GamePlanReportStyles.HeaderStyle.Name) .AlternateBackgroundColors(GamePlanReportStyles.AlternateBackgroundColors); var currencyFormatter = new CurrencyReportFormatter(); confBuilder .ForMember(с => с.DemoGraphic, o => o.Header("Demographic")) .ForMember(с => с.Payback, o => o.Formatter(currencyFormatter)) .ForMember(с => с.RevenueBooked, o => o.Formatter(currencyFormatter)) .ForMember(с => с.TopTail, o => o.Header("Top/Tail")) .ForMember(с => с.RatingsDifferenceExcludingPayback, o => o.Formatter(ReportFormatter.DecimalRoundingFormatter).Header("+/- Ratings Excl. PB")) .ForMember(с => с.ValueDifference, o => o.Formatter(currencyFormatter).Header("+/- Value")) .ForMember(с => с.ValueDifferenceExcludingPayback, o => o.Formatter(currencyFormatter).Header("+/- Value Excl. PB")) .ForMember(с => с.AchievedPercentageTargetRatings, o => o.Formatter(ReportFormatter.DecimalRoundingFormatter).Header("Achieved % (ratings)")) .ForMember(с => с.AchievedPercentageRevenueBudget, o => o.Formatter(ReportFormatter.DecimalRoundingFormatter).Header("Achieved % (value)")) .ForMember(с => с.Spots, o => o.Header("Spots (actual)")) .ForMember(с => с.CreationDate, o => o.Formatter(ReportFormatter.ConvertToShortDate)) .ForMember(с => с.ProductAssignee, o => o.Header("Person (Product Assignee)")) .ForMember(с => с.MediaSalesGroup, o => o.Header("Media Group")); return(confBuilder); }
public List <T> ApplySettings <T>(IEnumerable <T> data, IEnumerable <ColumnStatusModel> columnStatusModelList, ExcelConfigurationBuilder <T> configurationBuilder) where T : class { var orderData = data?.ToList() ?? new List <T>(); if (!orderData.Any() || columnStatusModelList is null || !columnStatusModelList.Any() || configurationBuilder == null) { return(orderData); } var sortFields = new List <string>(); foreach (var columnStatusModel in columnStatusModelList) { if (columnStatusModel.Ignore) { configurationBuilder.ForMember(columnStatusModel.Name, o => o.Ignore()); } else { configurationBuilder.ForMember(columnStatusModel.Name, o => o.Order(columnStatusModel.Order)); if (String.Equals(columnStatusModel.SortDirection, "ASC", StringComparison.OrdinalIgnoreCase) || String.Equals(columnStatusModel.SortDirection, "DESC", StringComparison.OrdinalIgnoreCase)) { sortFields.Add(columnStatusModel.Name + " " + columnStatusModel.SortDirection); } } } if (sortFields.Any()) { orderData = data.AsQueryable().OrderBy(String.Join(",", sortFields)).ToList(); } return(orderData); }