public async Task <ActionResult> Download(int urn) { var schoolDetailsFromEdubase = _contextDataService.GetSchoolByUrn(urn.ToString()); SchoolViewModel schoolVM = await BuildSchoolVMAsync(RevenueGroupType.AllIncludingSchoolPerf, ChartGroupType.All, CentralFinancingType.Include, schoolDetailsFromEdubase); var termsList = BuildTermsList(schoolVM.FinancialType); _fcService.PopulateHistoricalChartsWithSchoolData(schoolVM.HistoricalCharts, schoolVM.HistoricalSchoolFinancialDataModels, termsList.First(), RevenueGroupType.AllExcludingSchoolPerf, UnitType.AbsoluteMoney, schoolVM.FinancialType); var latestYear = _financialDataService.GetLatestDataYearPerSchoolType(schoolVM.FinancialType); var csv = _csvBuilder.BuildCSVContentHistorically(schoolVM, latestYear); return(File(Encoding.UTF8.GetBytes(csv), "text/plain", $"HistoricalData-{urn}.csv")); }
/// <summary> /// Step 3 - Advanced /// </summary> /// <param name="urn"></param> /// <param name="estType"></param> /// <param name="comparisonType"></param> /// <param name="areaType"></param> /// <param name="lacode"></param> /// <returns></returns> public ActionResult AdvancedCharacteristics(string urn, ComparisonType comparisonType, EstablishmentType estType, ComparisonArea?areaType, int?lacode, string laNameText, BenchmarkCriteria AdvancedCriteria) { if (areaType == ComparisonArea.LaName && !string.IsNullOrEmpty(laNameText) && lacode == null) { var exactLaMatch = _laSearchService.SearchExactMatch(laNameText); if (exactLaMatch != null) { lacode = Int32.Parse(exactLaMatch.id); } } ViewBag.URN = urn; ViewBag.ComparisonType = comparisonType; ViewBag.EstType = estType; ViewBag.AreaType = areaType; ViewBag.LaCode = lacode; var benchmarkSchool = new SchoolViewModel(_contextDataService.GetSchoolByUrn(urn), base.ExtractSchoolComparisonListFromCookie()); var latestYear = _financialDataService.GetLatestDataYearPerSchoolType(benchmarkSchool.FinancialType); var term = FormatHelpers.FinancialTermFormatAcademies(latestYear); var document = _financialDataService.GetSchoolDataDocument(urn, term, benchmarkSchool.FinancialType); benchmarkSchool.HistoricalSchoolFinancialDataModels = new List <SchoolFinancialDataModel> { new SchoolFinancialDataModel(urn, term, document, benchmarkSchool.FinancialType) }; if (!IsAreaFieldsValid(areaType, lacode, benchmarkSchool)) { ViewBag.Authorities = _laService.GetLocalAuthorities(); return(View("ChooseRegion", benchmarkSchool)); } var schoolCharsVM = new SchoolCharacteristicsViewModel(benchmarkSchool, base.ExtractSchoolComparisonListFromCookie(), AdvancedCriteria); return(View(schoolCharsVM)); }
public async Task <PartialViewResult> CustomReport(string json, ChartFormat format) { var customSelection = (CustomSelectionListViewModel)JsonConvert.DeserializeObject(json, typeof(CustomSelectionListViewModel)); var customCharts = ConvertSelectionListToChartList(customSelection.HierarchicalCharts); var comparisonList = base.ExtractSchoolComparisonListFromCookie(); var financialDataModels = await this.GetFinancialDataForSchoolsAsync(comparisonList.BenchmarkSchools, (CentralFinancingType)Enum.Parse(typeof(CentralFinancingType), customSelection.CentralFinance)); var trimSchoolNames = Request.Browser.IsMobileDevice; _fcService.PopulateBenchmarkChartsWithFinancialData(customCharts, financialDataModels, comparisonList.BenchmarkSchools, comparisonList.HomeSchoolUrn, null, trimSchoolNames); var academiesTerm = FormatHelpers.FinancialTermFormatAcademies(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Academies)); var maintainedTerm = FormatHelpers.FinancialTermFormatMaintained(_financialDataService.GetLatestDataYearPerSchoolType(SchoolFinancialType.Maintained)); var vm = new BenchmarkChartListViewModel(customCharts, base.ExtractSchoolComparisonListFromCookie(), null, ComparisonType.Manual, null, null, null, EstablishmentType.All, EstablishmentType.All, null, null, academiesTerm, maintainedTerm, ComparisonArea.All, null, null, ComparisonListLimit.DEFAULT); ViewBag.ChartFormat = format; return(PartialView("Partials/CustomCharts", vm)); }