/** Method initializes a process of saving and absance model to the database */ private void saveButton_Click(object sender, EventArgs e) { if (!this.isDateTimeValid()) { feedbackWindow.setCustomizedMessage(validationMessage); feedbackWindow.ShowDialog(); validationMessage = ""; return; } AbsenceModel absence = this.getAbsenceModelFromPresenterForm(); List <string> invalidFields = new List <string>(); AbsenceController controller = new AbsenceController(); if (allTheDoctors.Enabled) { invalidFields = controller.isDataValid(startDatePicker, endDatePicker, startTimePicker, endTimePicker, invalidFields, allTheDoctors); } else { invalidFields = controller.isDataValid(startDatePicker, endDatePicker, startTimePicker, endTimePicker, invalidFields); } if (invalidFields == null || invalidFields.Count == 0) { if (!controller.save(absence)) { this.feedbackWindow.setMessageForAbsencesProblems(); } else { this.feedbackWindow.setMessageForSuccessfullOperation(); } } else { feedbackWindow.setMessageForInvalidFieldsValues(invalidFields); } feedbackWindow.ShowDialog(); }
private void FinishedExerciseClick(object param) { FeedbackWindow window = new FeedbackWindow(); FeedbackViewModel vm = new FeedbackViewModel(window); window.DataContext = vm; Feedback feedback = Feedback.Medium; bool? result = window.ShowDialog(); if (result == true) { feedback = vm.UserFeedback; } try { CurrentUser.ExerciseCompleted(feedback); } catch (SqlException) { MessageBox.Show($"Kunne ikke oprette forbindelse til databasen!"); } UpdateExerciseDesc(); }