private HomeModel CreateHomeModel(UserType preferredUserType, Login login, MemberJoin join, bool acceptTerms) { var country = ActivityContext.Location.Country; var qna = _resourcesQuery.GetQnA(_resourcesQuery.GetFeaturedQnAs().Single().ResourceId); return(new HomeModel { PreferredUserType = preferredUserType, Login = login, Join = join, AcceptTerms = acceptTerms, Reference = new ReferenceModel { MinSalary = JobAdSearchCriteria.MinSalary, MaxSalary = JobAdSearchCriteria.MaxSalary, StepSalary = JobAdSearchCriteria.StepSalary, MinHourlySalary = JobAdSearchCriteria.MinHourlySalary, MaxHourlySalary = JobAdSearchCriteria.MaxHourlySalary, StepHourlySalary = JobAdSearchCriteria.StepHourlySalary, Industries = GetIndustries(), FeaturedStatistics = GetFeaturedStatistics(), FeaturedEmployers = GetFeaturedEmployers(), FeaturedJobAds = GetFeaturedJobAds(), FeaturedCandidateSearches = GetFeaturedCandidateSearches(), Countries = _locationQuery.GetCountries(), CountrySubdivisions = (from s in _locationQuery.GetCountrySubdivisions(country) where !s.IsCountry select s).ToList(), Regions = _locationQuery.GetRegions(country), DefaultCountry = country, FeaturedAnsweredQuestion = qna, Categories = _resourcesQuery.GetCategories(), } }); }
private ActionResult View(Login login, LoginReason?reason, MemberJoin join, bool acceptTerms) { return(View("Account", new LoginModel { Login = login ?? new Login(), Reason = reason, Join = join ?? new MemberJoin(), AcceptTerms = acceptTerms, })); }
protected ActionResult TryJoin(MemberJoin join, CheckBoxValue acceptTerms, Func <IErrorHandler> createErrorHandler) { try { join = join ?? new MemberJoin(); // 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 MemberAccount { FirstName = join.FirstName, LastName = join.LastName, EmailAddress = join.EmailAddress, }; var credentials = new AccountLoginCredentials { LoginId = join.EmailAddress, Password = join.JoinPassword, ConfirmPassword = join.JoinConfirmPassword, }; _accountsManager.Join(HttpContext, account, credentials, true); return(RedirectToUrl(JoinUrl)); } // 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 Home(MemberJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { var result = TryJoin(joinModel, acceptTerms, () => new HomeErrorHandler(HttpContext.GetLoginUrl(), Accounts.Routes.AccountsRoutes.NewPassword.GenerateUrl())); return(result ?? View(CreateHomeModel(UserType.Anonymous, null, joinModel, acceptTerms != null && acceptTerms.IsChecked))); }
public ActionResult LogIn(MemberJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { var result = TryJoin(joinModel, acceptTerms); return(result ?? View(null, null, joinModel, acceptTerms != null && acceptTerms.IsChecked)); }
protected ActionResult TryJoin(MemberJoin join, CheckBoxValue acceptTerms) { return(TryJoin(join, acceptTerms, () => new StandardErrorHandler())); }