void IMemberAccountsCommand.CreateMember(Member member, LoginCredentials credentials, Guid?affiliateId) { // Check login credentials. if (_loginCredentialsQuery.DoCredentialsExist(credentials)) { throw new DuplicateUserException(); } // Set some defaults. member.IsEnabled = true; member.AffiliateId = affiliateId; PrepareEmailAddresses(member); // Save. CreateMember(member, affiliateId); _loginCredentialsCommand.CreateCredentials(member.Id, credentials); // Fire events. var handlers = MemberCreated; if (handlers != null) { handlers(this, new MemberCreatedEventArgs(member.Id)); } }
void IAdministratorAccountsCommand.CreateAdministrator(Administrator administrator, LoginCredentials credentials) { // Check login credentials. if (_loginCredentialsQuery.DoCredentialsExist(credentials)) { throw new DuplicateUserException(); } // Set some defaults. administrator.IsEnabled = true; administrator.IsActivated = true; // Always make sure the email is verified when created. if (administrator.EmailAddress != null) { administrator.EmailAddress.IsVerified = true; } // Save. _administratorsCommand.CreateAdministrator(administrator); _loginCredentialsCommand.CreateCredentials(administrator.Id, credentials); }
void ICustodianAccountsCommand.CreateCustodian(Custodian custodian, LoginCredentials credentials, Guid affiliateId) { // Check login credentials. if (_loginCredentialsQuery.DoCredentialsExist(credentials)) { throw new DuplicateUserException(); } // Set some defaults. custodian.IsEnabled = true; custodian.IsActivated = true; // Always make sure the email is verified when created. if (custodian.EmailAddress != null) { custodian.EmailAddress.IsVerified = true; } // Save. _custodiansCommand.CreateCustodian(custodian); _loginCredentialsCommand.CreateCredentials(custodian.Id, credentials); _custodianAffiliationsCommand.SetAffiliation(custodian.Id, affiliateId); custodian.AffiliateId = affiliateId; }
private void UpdateCredentials(Guid employerId, LoginCredentials credentials, string loginId, string password, string confirmPassword, bool useLinkedInProfile) { if (credentials == null) { if (!string.IsNullOrEmpty(loginId) || !string.IsNullOrEmpty(password) || !string.IsNullOrEmpty(confirmPassword)) { // No existing credentials but trying to create some. var credentialsModel = new LoginCredentialsModel { LoginId = loginId, Password = password, ConfirmPassword = confirmPassword }; credentialsModel.Validate(); _loginCredentialsCommand.CreateCredentials(employerId, new LoginCredentials { LoginId = loginId, PasswordHash = LoginCredentials.HashToString(password) }); } } else { if (loginId != credentials.LoginId) { // Cannot remove the login id. if (string.IsNullOrEmpty(loginId)) { throw new ValidationErrorsException(new RequiredValidationError("LoginId")); } // Check not trying to someone else's login id. if (_loginCredentialsQuery.DoCredentialsExist(new LoginCredentials { LoginId = loginId })) { throw new DuplicateUserException(); } // Update the credentials. credentials.LoginId = loginId; _loginCredentialsCommand.UpdateCredentials(employerId, credentials, employerId); } // If not wanting to use LinkedIn any more then remove the profile. if (!useLinkedInProfile) { _linkedInCommand.DeleteProfile(employerId); } } }
void IEmployerAccountsCommand.CreateEmployer(Employer employer, LoginCredentials credentials) { // Check login credentials. if (_loginCredentialsQuery.DoCredentialsExist(credentials)) { throw new DuplicateUserException(); } // Create the employer. CreateEmployer(employer); // Create the credentials. _loginCredentialsCommand.CreateCredentials(employer.Id, credentials); }
void ICustodiansCommand.CreateCustodian(Custodian custodian, LoginCredentials credentials) { if (_loginCredentialsQuery.DoCredentialsExist(credentials)) { throw new DuplicateUserException(); } // Set some defaults. custodian.IsEnabled = true; custodian.IsActivated = true; // Save. //_userProfileBroker.SaveNewUser(custodian); _loginCredentialsCommand.CreateCredentials(custodian.Id, credentials); }
void IAdministratorsCommand.CreateAdministrator(Administrator administrator, LoginCredentials credentials) { if (_loginCredentialsQuery.DoCredentialsExist(credentials)) { throw new DuplicateUserException(); } // Set some defaults. administrator.IsEnabled = true; administrator.IsActivated = true; // Save. //_userProfileBroker.SaveNewUser(administrator); _loginCredentialsCommand.CreateCredentials(administrator.Id, credentials); }
private static void CreateInvalidMember(Member member, LoginCredentials credentials, Guid?affiliateId) { // Check login credentials. if (LoginCredentialsQuery.DoCredentialsExist(credentials)) { throw new DuplicateUserException(); } // Set some defaults. member.IsEnabled = true; member.AffiliateId = affiliateId; // Save. member.Prepare(); MembersRepository.CreateMember(member); var candidate = new Candidate { Id = member.Id, Status = Defaults.CandidateStatus, DesiredJobTypes = Defaults.DesiredJobTypes, RelocationPreference = Defaults.RelocationPreference, }; CandidatesCommand.CreateCandidate(candidate); if (affiliateId != null) { MemberAffiliationsCommand.SetAffiliation(member.Id, affiliateId.Value); } LoginCredentialsCommand.CreateCredentials(member.Id, credentials); //Update search //MemberSearchService.UpdateMember(member.Id); }