private void btnAttendanceSave_Click(object sender, RoutedEventArgs e) { if (SelectedDate.IsValidDate() && SelectedClassID > 0) { foreach (var item in StudentAttendanceList) { Attendance atnd = new Attendance { ClassID = SelectedClassID, StudentID = SelectedStudenID, SessionID = SessionID, isPresent = item.isPresent, updated_by = UserID }; if (item.isExisted) { AttendanceRepo.Update(atnd); } else { atnd.created_by = UserID; AttendanceRepo.Insert(atnd); } } } else { Message(MessageTypes.Error, "Please Select the date and Class"); } }