public void SaveExecute(object parametar) { var passwordBox = parametar as PasswordBox; var password = passwordBox.Password; User.Password = password; User.GenderId = selectedGender.GenderId; User.RoleId = 5; try { bool uniqueInsuranceNumber = service.CheckInsuranceNumber(UserPatient.InsuranceNumber); int drUniqueNumber = service.GetDoctorUniqueNumberByDoctorId(selectDoctor.ClinicUserId); if (uniqueInsuranceNumber) { int userId = service.AddClinicUser(User); if (userId != 0) { UserPatient.ClinicUserId = userId; UserPatient.UniqueDoctorNumber = drUniqueNumber; if (service.AddNewPatient(UserPatient) != 0) { MessageBox.Show("You have successfully added new patient"); Logging.LoggAction("AddPatientViewModel", "Info", "Succesfull added new doctor"); PatientView patientView = new PatientView(UserAdmin); patientView.Show(); addPatientView.Close(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logging.LoggAction("AddDoctorViewModel", "Error", ex.ToString()); } }