private void ExecuteSave(object p) { try { if (!ServiceDataProvider.ValidateExamInExamPeriod(ExamPeriodId, CourseId)) { MessageBox.Show("Exam for Course already exists in Exam Period!", "Exam Validation", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (editExam != null) { editExam.ExamPeriodId = ExamPeriodId; editExam.CourseId = CourseId; editExam.DateAndTime = DateAndTime.Value; editExam.Place = Place; editExam.Price = Price; editExam.IsPassed = IsPassed; ServiceDataProvider.EditExam(editExam); } else { Exam exam = new Exam() { ExamPeriodId = ExamPeriodId, CourseId = CourseId, DateAndTime = DateAndTime.Value, Place = Place, Price = Price, IsPassed = IsPassed }; ServiceDataProvider.AddExam(exam); } } catch (Exception ex) { ex.Message.ToString(); } finally { view.Close(); } }