public async Task GetAllRecordsFromMultipleDbset() { //Act var schoolLst = await _repositorySchool.GetAll(x => x.SchoolResults); //Count number of results for all schools in test database //to see if school results objects was included var resultCount = schoolLst.SelectMany(s => s.SchoolResults.Select(x => x.URN)).Count(); //Assert Assert.AreEqual(_schoolResults.Where(s => s.URN != 9).Count(), resultCount); //Act schoolLst = await _repositorySchool.Get(null, x => x.SchoolResults); resultCount = schoolLst.SelectMany(s => s.SchoolResults.Select(x => x.URN)).Count(); //Assert Assert.AreEqual(_schoolResults.Where(s => s.URN != 9).Count(), resultCount); }
public async Task <IActionResult> GetResultsDisadvantaged() { _logger.LogInformation("Request made to get JSON object with data for Table All page"); //Check if data is in cache var resultViewModel = await _cache.GetTableDataDisadvantaged(); //Get results for all schools if data is not in cache if (resultViewModel.Count() == 0) { _logger.LogInformation("Table disadvantaged data is being retrieved from the database"); //Get results for all schools //where the percentage of disadvantaged pupils is not null var result = await _result.Get( r => r.PTFSM6CLA1A != null, r => r.OrderBy(s => s.School.SCHNAME), r => r.School); //Converts from list of SchoolResult to List of TableViewModel resultViewModel = result.ConvertToTableViewModelDisadvantaged(); //Save list of TableViewModel data to cache await _cache.SaveTableDataDisadvantaged(resultViewModel); } //Check if data is in cache var resultNatViewModel = await _cache.GetNationalTableDataDisadvantaged(); //Get the national data from database if not in cache if (resultNatViewModel == null) { _logger.LogInformation("Table national disadvantaged data is being retrieved from the database"); var nationalResultLst = await _result.GetNational(); //Because there is only currently national data for 2019 there should only be 1 result var nationalResult = nationalResultLst.First(); //Convert national SchoolResult object to a TableViewModel object resultNatViewModel = nationalResult; //Save National TableViewModel data to cache await _cache.SaveNationalTableDataDisadvantaged(resultNatViewModel); } var data = new { data = resultViewModel, national = resultNatViewModel }; return(Json(data)); }
public async Task <IActionResult> Index() { _logger.LogInformation("Request made to view Scatterplot page"); //Check if data is in cache and if so get the data from cache IEnumerable <ScatterplotViewModel> schoolLst = await _cache.GetScatterplotData(); ScatterplotViewModel national = await _cache.GetNationalScatterplotData(); //if data is not in cache get data from database and save data in cache if (schoolLst.Count() == 0) { _logger.LogInformation("Scatterplot data is being retrieved from the database"); var result = await _result.Get(r => r.PTFSM6CLA1A != null, r => r.OrderBy(s => s.School.SCHNAME), r => r.School); //Converts from list of SchoolResult to List of ScatterplotViewModel schoolLst = result.ConvertToScatterplotViewModel(); await _cache.SaveScatterplotData(schoolLst); } //if national data is not in cache get data from database and save data in cache if (national == null) { _logger.LogInformation("National Scatterplot data is being retrieved from the database"); var result = await _result.GetNational(r => r.School); national = result.First(); await _cache.SaveNationalScatterplotData(national); } var resultViewModel = new ScatterplotListViewModel() { schoolData = schoolLst, nationalData = national, }; return(View(resultViewModel)); }
public async Task FilterRecordsFromADbsetAndOrder() { //Act //Gets the first school name in school using Get method //when data is filtered by PTL2BASICS_94 above 0.6 and ordered by PTL2BASICS_94 //National results should be excluded var schoolLst = await _repositorySchoolResult.Get( x => x.PTL2BASICS_94 >= 0.60, x => x.OrderBy(n => n.PTL2BASICS_94)); var schoolName = schoolLst.First().School.SCHNAME; //Assert Assert.AreEqual( _schoolResults.Where(x => x.PTL2BASICS_94 >= 0.60 && x.URN != 9) .OrderBy(n => n.PTL2BASICS_94).First().School.SCHNAME, schoolName); }