private Member TryJoin(PersonalDetailsMemberModel memberModel, IHavePasswords passwordsModel, Guid?friendInvitationId) { var account = new MemberAccount { FirstName = memberModel.FirstName, LastName = memberModel.LastName, EmailAddress = memberModel.EmailAddress }; var credentials = new AccountLoginCredentials { LoginId = memberModel.EmailAddress, Password = passwordsModel.Password, ConfirmPassword = passwordsModel.ConfirmPassword, }; // If the user is responding to an invitation then don't need to activate, unless they have changed their email. var friendInvitation = GetFriendInvitation(friendInvitationId); var acceptingFriendInvitation = friendInvitation != null && string.Equals(account.EmailAddress, friendInvitation.InviteeEmailAddress, StringComparison.OrdinalIgnoreCase); var requiresActivation = !acceptingFriendInvitation; // Join. var member = _accountsManager.Join(HttpContext, account, credentials, requiresActivation); // Deal with the invitations. if (acceptingFriendInvitation) { AcceptFriendInvitation(member.Id, friendInvitation); } return(member); }
protected ActionResult TryJoin(EmployerJoin join, CheckBoxValue acceptTerms, Func <IErrorHandler> createErrorHandler) { try { join = join ?? new EmployerJoin(); // Process the post to check validations. if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, createErrorHandler()); } // Try to join. if (acceptTerms != null && acceptTerms.IsChecked) { var account = new EmployerAccount { FirstName = join.FirstName, LastName = join.LastName, OrganisationName = join.OrganisationName, EmailAddress = join.EmailAddress, PhoneNumber = join.PhoneNumber, SubRole = join.SubRole, Location = join.Location, IndustryIds = join.IndustryIds, }; var credentials = new AccountLoginCredentials { LoginId = join.JoinLoginId, Password = join.JoinPassword, ConfirmPassword = join.JoinConfirmPassword, }; _accountsManager.Join(HttpContext, account, credentials); return(RedirectToReturnUrl()); } // Not accepting terms so cannot proceed but also check whether any other fields fail validation. join.Prepare(); join.Validate(); } catch (UserException ex) { ModelState.AddModelError(ex, createErrorHandler()); } return(null); }
public ActionResult Join(MemberJoin joinModel, bool acceptTerms) { try { joinModel = joinModel ?? new MemberJoin(); // Process the post to check validations. if (acceptTerms) { // Try to join. var account = new MemberAccount { FirstName = joinModel.FirstName, LastName = joinModel.LastName, EmailAddress = joinModel.EmailAddress, }; var credentials = new AccountLoginCredentials { LoginId = joinModel.EmailAddress, Password = joinModel.JoinPassword, ConfirmPassword = joinModel.JoinConfirmPassword, }; _accountsManager.Join(HttpContext, account, credentials, true); } else { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new StandardErrorHandler()); // Not accepting terms so cannot proceed but also check whether any other fields fail validation. joinModel.Prepare(); joinModel.Validate(); } } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }
public ActionResult Join(EmployerJoinModel joinModel) { try { joinModel.Validate(); // Try to join. var account = new EmployerAccount { FirstName = joinModel.FirstName, LastName = joinModel.LastName, EmailAddress = joinModel.EmailAddress, Location = joinModel.Location, OrganisationName = joinModel.OrganisationName, PhoneNumber = joinModel.PhoneNumber, SubRole = joinModel.SubRole, }; var credentials = new AccountLoginCredentials { LoginId = joinModel.LoginId, Password = joinModel.Password, ConfirmPassword = joinModel.Password, }; _accountsManager.Join(HttpContext, account, credentials); return(Json(new JsonResponseModel())); } catch (DuplicateUserException ex) { ModelState.AddModelError("LoginId", ex.Message); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }
private Employer CreateEmployer(EmployerJoin join) { var account = new EmployerAccount { FirstName = join.FirstName, LastName = join.LastName, EmailAddress = join.EmailAddress, PhoneNumber = join.PhoneNumber, OrganisationName = join.OrganisationName, Location = join.Location, SubRole = join.SubRole, IndustryIds = join.IndustryIds }; var credentials = new AccountLoginCredentials { LoginId = join.JoinLoginId, Password = join.JoinPassword, ConfirmPassword = join.JoinConfirmPassword, }; return(_accountsManager.Join(HttpContext, account, credentials)); }