예제 #1
0
 private LinkedInAccountModel GetAccountModel(LinkedInJoin join)
 {
     return(GetAccountModel(
                new Login(),
                join,
                false));
 }
예제 #2
0
 private LinkedInAccountModel GetAccountModel(Login login, LinkedInJoin join, bool acceptTerms)
 {
     return(new LinkedInAccountModel
     {
         Login = login ?? new Login(),
         Join = join ?? new LinkedInJoin(),
         AcceptTerms = acceptTerms,
         Industries = _industriesQuery.GetIndustries()
     });
 }
예제 #3
0
        public ActionResult Join(LinkedInJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms)
        {
            var profile = _linkedInQuery.GetProfile(CurrentAnonymousUser.Id);

            if (profile == null)
            {
                return(RedirectToRoute(HomeRoutes.Home));
            }

            try
            {
                joinModel = joinModel ?? new LinkedInJoin();

                // Process the post to check validations.

                if (acceptTerms == null || !acceptTerms.IsChecked)
                {
                    ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new StandardErrorHandler());
                }

                // Try to join.

                if (acceptTerms != null && acceptTerms.IsChecked)
                {
                    var account = new EmployerAccount
                    {
                        FirstName        = joinModel.FirstName,
                        LastName         = joinModel.LastName,
                        EmailAddress     = joinModel.EmailAddress,
                        PhoneNumber      = joinModel.PhoneNumber,
                        OrganisationName = joinModel.OrganisationName,
                        Location         = joinModel.Location,
                        SubRole          = joinModel.SubRole,
                        IndustryIds      = joinModel.IndustryIds
                    };

                    _accountsManager.Join(HttpContext, account, profile);
                    return(RedirectToReturnUrl());
                }

                // 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(View("Account", GetAccountModel(joinModel)));
        }