public void SaveExecute(object parametar) { var passwordBox = parametar as PasswordBox; var password = passwordBox.Password; User.Password = password; User.GenderId = selectedGender.GenderId; User.RoleId = 4; try { if (User.ClinicUserId == 0) { bool uniqueNumber = service.CheckUniqueNumber(UserDoctor.UniqueNumber); bool uniqueBancAccount = service.CheckBancAccount(UserDoctor.BancAccount); if (uniqueNumber && uniqueBancAccount) { int userId = service.AddClinicUser(User); if (userId != 0) { UserDoctor.ClinicUserId = userId; UserDoctor.DepartmentId = selectedDepartment.DepartmentId; UserDoctor.WorkShiftId = selectedWorkShift.WorkShiftId; UserDoctor.ClinicManagerId = selectedManager.ClinicManagerId; if (service.AddNewDoctor(UserDoctor) != 0) { MessageBox.Show("You have successfully added new doctor"); Logging.LoggAction("AddDoctorViewModel", "Info", "Succesfull added new doctor"); DoctorView doctorView = new DoctorView(UserAdmin); doctorView.Show(); addDoctorView.Close(); } } } } else { int userId = service.AddClinicUser(User); if (userId != 0) { UserDoctor.ClinicUserId = userId; UserDoctor.DepartmentId = selectedDepartment.DepartmentId; UserDoctor.WorkShiftId = selectedWorkShift.WorkShiftId; UserDoctor.ClinicManagerId = selectedManager.ClinicManagerId; if (service.AddNewDoctor(UserDoctor) != 0) { MessageBox.Show("You have successfully added new doctor"); Logging.LoggAction("AddDoctorViewModel", "Info", "Succesfull added new doctor"); DoctorView doctorView = new DoctorView(UserAdmin); doctorView.Show(); addDoctorView.Close(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logging.LoggAction("AddDoctorViewModel", "Error", ex.ToString()); } }