private async Task <List <SchoolFinancialDataModel> > GetFinancialDataHistoricallyAsync(string matCode, MatFinancingType matFinancing) { var models = new List <SchoolFinancialDataModel>(); var latestYear = _financialDataService.GetLatestDataYearForTrusts(); var taskList = new List <Task <IEnumerable <Document> > >(); for (int i = ChartHistory.YEARS_OF_HISTORY - 1; i >= 0; i--) { var term = FormatHelpers.FinancialTermFormatAcademies(latestYear - i); var task = _financialDataService.GetMATDataDocumentAsync(matCode, term, matFinancing); taskList.Add(task); } for (int i = ChartHistory.YEARS_OF_HISTORY - 1; i >= 0; i--) { var term = FormatHelpers.FinancialTermFormatAcademies(latestYear - i); var taskResult = await taskList[ChartHistory.YEARS_OF_HISTORY - 1 - i]; var resultDocument = taskResult?.FirstOrDefault(); if (resultDocument != null && resultDocument.GetPropertyValue <bool>("DNS")) { var emptyDoc = new Document(); emptyDoc.SetPropertyValue("DNS", true); resultDocument = emptyDoc; } models.Add(new SchoolFinancialDataModel(matCode, term, resultDocument, SchoolFinancialType.Academies)); } return(models); }