public void AddGrade() { //create the student var newStudent = new Student() { FirstName = "Mikesh", LastName = "Mistry" }; //add the student studentRepository.Add(newStudent); //Find the student var foundStudent = studentRepository.GetAll().ToList(); //create a course var newCourse = new Course() { Name = "Introduction To C# Programming", Description = "Introduction To C# Programming" }; //add the course to the database courseRepository.Add(newCourse); //find the course var foundCourse = courseRepository.GetAll().ToList(); //create a new grade var newGrade = new Grade() { Student = newStudent, Course = newCourse, LetterGrade = "A+" }; //add the grade gradeRepository.Add(newGrade); //find the grade var foundGrade = gradeRepository.Find(grade => grade.Student.StudentId == foundStudent[0].StudentId && grade.Course.CourseId == foundCourse[0].CourseId ).FirstOrDefault(); //test to see if we found the grade Assert.IsNotNull(foundGrade); //check are all the values the same Assert.AreEqual(foundGrade.Course.CourseId, foundCourse[0].CourseId); Assert.AreEqual(foundGrade.Student.StudentId, foundStudent[0].StudentId); Assert.AreEqual(foundGrade.LetterGrade, newGrade.LetterGrade); }
public List <Grade> GetGradeFiltered(String query) { if (query != null) { return(_gradeRepository.Find(a => a.Name.Contains(query)) .OrderBy(a => a.GradeId) .Skip(0) .Take(25).ToList <Grade>()); } else { return(_gradeRepository.GetAll().OrderBy(a => a.GradeId).Skip(0).Take(25).ToList <Grade>()); } }