//Tests GetByUrnOrLAESATB method gets a school by it's LAESTAB number public async Task GetByUrnOrLAESATBGetsSchoolByLAESTAB() { //Act //Gets the first School object //where URN or LAESATB == 1022000 var schoolLst = await _repositorySchool.GetByUrnOrLAESATB(1022000); var schoolURN = schoolLst.First().URN; //Assert Assert.AreEqual( _schools.Where(x => x.LA == 102 && x.ESTAB == 2000).First().URN, schoolURN); }
//Tests GetByUrnOrLAESATB method gets a school by it's URN public async Task GetByUrnOrLAESATBGetsSchoolByURN() { //Act //Gets the first School object //where URN or LAESATB == 2 var schoolLst = await _repositorySchoolResult.GetByUrnOrLAESATB(2); var schoolURN = schoolLst.First().URN; //Assert Assert.AreEqual( _schools.Where(x => x.URN == 2).First().URN, schoolURN); }
public async Task <IActionResult> Index(int id) { _logger.LogInformation($"Request made to view School page with id: {id}"); _logger.LogInformation($"Data for {id} is being retrieved from the database"); //Get the school data for the 2019 academic year var schoolResult = await _result .GetByUrnOrLAESATB(id, s => s.ACADEMICYEAR == 2019, s => s.School); var schoolContextual = await _contextual .GetByUrnOrLAESATB(id, s => s.ACADEMICYEAR == 2019); //Return a page letting the user know the id cannot be found //If the school id does not exist if (schoolResult.Count() == 0) { return(View("SchoolNotFound", id)); } _logger.LogInformation($"National data is being retrieved from the database"); //Get the national data var nationalResult = await _result.GetNational(s => s.ACADEMICYEAR == 2019, s => s.School); var nationalContextual = await _contextual.GetNational(s => s.ACADEMICYEAR == 2019); //Add School and National data to the SchoolViewModel var schoolViewModel = new SchoolViewModel() { ResultSchool = schoolResult.First(), ResultNational = nationalResult.First(), ContextualSchool = schoolContextual.First(), ContextualNational = nationalContextual.First() }; return(View(schoolViewModel)); }