public void AddCourses() { foreach (var item in _allCourses) { if (item.IsSelected == true) { CompletedCourseModel CompletedCourse = new CompletedCourseModel { StudentId = UserName, CourseId = item.CourseId }; _sqlData.InsertCompletedCourse(CompletedCourse.StudentId, CompletedCourse.CourseId); } else if (item.IsSelected == false) { CompletedCourseModel CompletedCourse = new CompletedCourseModel { StudentId = UserName, CourseId = item.CourseId }; _sqlData.RemoveCompletedCourse(CompletedCourse.StudentId, CompletedCourse.CourseId); } } _eventAggregator.PublishOnUIThread("1"); }