private async Task <SponsorViewModel> BuildSponsorVMAsync(string matNo, string name, dynamic response, RevenueGroupType tab, ChartGroupType chartGroup, MatFinancingType matFinancing)
        {
            var schoolListVM = new List <SchoolViewModel>();

            foreach (var result in response.Results)
            {
                schoolListVM.Add(new SchoolViewModel(result, null));
            }

            var comparisonListVM = base.ExtractSchoolComparisonListFromCookie();
            var sponsorVM        = new SponsorViewModel(matNo, name, new SchoolListViewModel(schoolListVM, comparisonListVM), comparisonListVM);

            sponsorVM.HistoricalCharts = _historicalChartBuilder.Build(tab, chartGroup, sponsorVM.FinancialType);
            sponsorVM.ChartGroups      = _historicalChartBuilder.Build(tab, sponsorVM.FinancialType).DistinctBy(c => c.ChartGroup).ToList();
            sponsorVM.Terms            = _financialDataService.GetActiveTermsForAcademies();

            sponsorVM.HistoricalSchoolFinancialDataModels = await this.GetFinancialDataHistoricallyAsync(sponsorVM.MatNo, matFinancing);

            if (sponsorVM.HistoricalSchoolFinancialDataModels.Count > 0)
            {
                sponsorVM.TotalRevenueIncome      = sponsorVM.HistoricalSchoolFinancialDataModels.Last().TotalIncome;
                sponsorVM.TotalRevenueExpenditure = sponsorVM.HistoricalSchoolFinancialDataModels.Last().TotalExpenditure;
                sponsorVM.InYearBalance           = sponsorVM.HistoricalSchoolFinancialDataModels.Last().InYearBalance;
            }
            return(sponsorVM);
        }
        public ActionResult AcademicYear(EstablishmentType estab)
        {
            ViewBag.Estab = estab;

            switch (estab)
            {
            case EstablishmentType.Academy:
            case EstablishmentType.MAT:
                ViewBag.Terms = _dataService.GetActiveTermsForAcademies();
                break;

            default:
                ViewBag.Terms = _dataService.GetActiveTermsForMaintained();
                break;
            }

            return(View("AcademicYear"));
        }