private void SetAttendance(IEnumerable <Guid> aStudentIds) { if (mAppService.AppState.SelectedSection.AttendingStudents != null) { return; } mAppService.AppState.SelectedSection.AttendingStudents = new ObservableCollection <AttendingStudent>(); foreach (Guid theGuid in aStudentIds) { var theStudent = mDataService.GetStudent(theGuid); if (theStudent != null) { AttendingStudents.Add(new AttendingStudent() { Id = theGuid, Name = theStudent.ToString(), IsAttending = true }); } } }
private void StudentIds_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.OldItems != null) { var theStudentsToRemove = new List <AttendingStudent>(); foreach (Guid theGuid in e.OldItems) { foreach (var theStudent in AttendingStudents) { if (theStudent.Id == theGuid) { theStudentsToRemove.Add(theStudent); } } } foreach (var theStudent in theStudentsToRemove) { AttendingStudents.Remove(theStudent); } } if (e.NewItems != null) { foreach (Guid theGuid in e.NewItems) { var theStudent = mDataService.GetStudent(theGuid); if (theStudent != null) { AttendingStudents.Add(new AttendingStudent() { Id = theGuid, Name = theStudent.ToString(), IsAttending = true }); } } } }