public void SaveExecute(object parametar) { var passwordBox = parametar as PasswordBox; var password = passwordBox.Password; var email = User.Email.ToLower(); User.Password = password; User.Email = email; User.RoleId = 2; try { if (User.HotelUserId == 0) { bool uniqueUserName = service.CheckUsername(User.Username); bool uniqueEmail = service.CheckEmail(User.Email); bool uniqueFloor = service.CheckHotelFloor(UserManager.HotelFloor); if (uniqueUserName && uniqueEmail && uniqueFloor) { int userId = service.AddHotelUser(User); if (userId != 0) { UserManager.HotelUserId = userId; UserManager.QualificationLevelId = selectedQualificationLevel.QualificationLevelId; if (service.AddNewManger(UserManager) != 0) { MessageBox.Show("You have successfully added new manager"); OwnerView ownerView = new OwnerView(); ownerView.Show(); addManagerView.Close(); } } } else if (!uniqueUserName) { MessageBox.Show("Username already exists!"); } else if (!uniqueEmail) { MessageBox.Show("Email already exists!"); } else if (!uniqueFloor) { MessageBox.Show("The floor is occupied select another!"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void SaveExecute(object parametar) { var passwordBox = parametar as PasswordBox; var password = passwordBox.Password; var email = User.Email.ToLower(); User.Password = password; User.Email = email; User.RoleId = 1; try { if (User.HotelUserId == 0) { bool uniqueUserName = service.CheckUsername(User.Username); bool uniqueEmail = service.CheckEmail(User.Email); if (uniqueUserName && uniqueEmail) { int userId = service.AddHotelUser(User); if (userId != 0) { UserWorker.HotelUserId = userId; UserWorker.GenderId = selectedGender.GenderId; UserWorker.HotelFloor = selectedFloor; UserWorker.EngagmentId = selectedEngagment.EngagmentId; UserWorker.QualificationLevelId = selectedQualificationLevel.QualificationLevelId; UserWorker.ManagerId = service.GetManagerByFloorNumber(selectedFloor); if (service.AddNewWorker(UserWorker) != 0) { MessageBox.Show("You have successfully added new worker"); OwnerView ownerView = new OwnerView(); ownerView.Show(); addworkerview.Close(); } } } else if (!uniqueUserName) { MessageBox.Show("Username already exists!"); } else if (!uniqueEmail) { MessageBox.Show("Email already exists!"); } 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()); } }