コード例 #1
0
        public async Task <ActionResult> Index(string matNo, string name, UnitType unit = UnitType.AbsoluteMoney, RevenueGroupType tab = RevenueGroupType.Expenditure, MatFinancingType financing = MatFinancingType.TrustAndAcademies, ChartFormat format = ChartFormat.Charts)
        {
            ChartGroupType chartGroup;

            switch (tab)
            {
            case RevenueGroupType.Expenditure:
                chartGroup = ChartGroupType.TotalExpenditure;
                break;

            case RevenueGroupType.Income:
                chartGroup = ChartGroupType.TotalIncome;
                break;

            case RevenueGroupType.Balance:
                chartGroup = ChartGroupType.InYearBalance;
                break;

            default:
                chartGroup = ChartGroupType.All;
                break;
            }

            var latestYear = _financialDataService.GetLatestDataYearForTrusts();
            var term       = FormatHelpers.FinancialTermFormatAcademies(latestYear);

            var dataResponse = _financialDataService.GetAcademiesByMatNumber(term, matNo);

            var sponsorVM = await BuildSponsorVMAsync(matNo, name, dataResponse, tab, chartGroup, financing);

            List <string> terms      = _financialDataService.GetActiveTermsForMatCentral();
            var           latestTerm = terms.First();

            UnitType unitType;

            switch (tab)
            {
            case RevenueGroupType.Workforce:
                unitType = UnitType.AbsoluteCount;
                break;

            case RevenueGroupType.Balance:
                unitType = unit == UnitType.AbsoluteMoney || unit == UnitType.PerPupil || unit == UnitType.PerTeacher ? unit : UnitType.AbsoluteMoney;
                break;

            default:
                unitType = unit;
                break;
            }

            _fcService.PopulateHistoricalChartsWithSchoolData(sponsorVM.HistoricalCharts, sponsorVM.HistoricalSchoolFinancialDataModels, latestTerm, tab, unitType, SchoolFinancialType.Academies);

            ViewBag.Tab         = tab;
            ViewBag.ChartGroup  = chartGroup;
            ViewBag.UnitType    = unitType;
            ViewBag.Financing   = financing;
            ViewBag.ChartFormat = format;

            return(View(sponsorVM));
        }
コード例 #2
0
        private List <SchoolFinancialDataModel> GetFinancialDataForTrusts(List <TrustToCompareViewModel> trusts, MatFinancingType matFinancing = MatFinancingType.TrustAndAcademies)
        {
            var models = new List <SchoolFinancialDataModel>();

            var terms = _financialDataService.GetActiveTermsForMatCentral();

            foreach (var trust in trusts)
            {
                var financialDataModel = _financialDataService.GetMATDataDocument(trust.MatNo, terms.First(), matFinancing);
                models.Add(new SchoolFinancialDataModel(trust.MatNo, terms.First(), financialDataModel, SchoolFinancialType.Academies));
            }

            return(models);
        }