public void GetAllGrades_ShouldReturnAllGrades() { var data = _service.GetAllGrades(); List <AllGradesVm> grades = new List <AllGradesVm>(); foreach (var grade in data) { grades.Add(grade); } Assert.AreEqual(2, grades.Count); }
public IHttpActionResult GetGrades() { var userData = IdentityHelper.GetLoggedInUser(RequestContext); logger.Info("Get Grades by {@userData}", userData); logger.Info("Get grades for logged in user --- auto dispatch"); var userInfo = Utilities.WebApi.IdentityHelper.FetchUserData(RequestContext); if (userInfo.UserId == null) { return(Unauthorized()); } var userId = userInfo.UserId ?? 0; if (userInfo.IsAdmin) { return(Ok(gradesService.GetAllGrades())); } else if (userInfo.IsTeacher) { return(Ok(gradesService.GetAllGradesForTeacher(userId))); } else if (userInfo.IsStudent) { return(Ok(gradesService.GetAllGradesForStudent(userId))); } else if (userInfo.IsParent) { return(Ok(gradesService.GetAllGradesForParent(userId))); } else { logger.Error("Authenticated user with no role --- this should not happen"); return(InternalServerError()); } }
public IEnumerable <Grade> GetAllGrades() { return(gradesService.GetAllGrades()); }