private void LoadEnrollements() { EnrollementViews.Clear(); var courses = db.GetCourses(); foreach (var enrollement in db.GetEnrollementsByStudent(Student)) { var view = new EnrollementView(); view.Enrollement = enrollement; view.Course = courses.Find(course => course.Id.Equals(enrollement.CourseId)); EnrollementViews.Add(view); } }
private void SubmitEnrollementForm(object sender, RoutedEventArgs e) { var found = EnrollementViews.Count(view => view.Enrollement.CourseId.Equals(FormCourseOffer.CourseId) && view.Enrollement.Semster.Equals(FormCourseOffer.Semster)) == 1; var enrollement = new Enrollement() { CourseId = FormCourseOffer.CourseId, Semster = FormCourseOffer.Semster, Grade = FormGrade, StudentId = Student.StudentId }; if (found) { //If found, update the grade db.SetGrade(enrollement); } else { //This is insertion process db.EnrollsInCourseOffering(enrollement); } LoadEnrollements(); }