Esempio n. 1
0
        private void Save(Login login, EmployerJoin join, bool acceptTerms)
        {
            // Save the employer.

            Pageflow.Login       = login;
            Pageflow.Join        = join;
            Pageflow.AcceptTerms = acceptTerms;
        }
Esempio n. 2
0
 private ActionResult AccountView(Login login, EmployerJoin join, bool acceptTerms)
 {
     return(View("Account", new AccountModel
     {
         Login = login,
         Join = join ?? new EmployerJoin(),
         AcceptTerms = acceptTerms,
         Industries = _industriesQuery.GetIndustries()
     }));
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 private ActionResult AccountView(Order order, Login login, EmployerJoin join, bool acceptTerms)
 {
     return(View(new NewOrderAccountModel
     {
         Account = new AccountModel
         {
             Login = login ?? new Login(),
             Join = join ?? new EmployerJoin(),
             AcceptTerms = acceptTerms,
             Industries = _industriesQuery.GetIndustries()
         },
         OrderDetails = _employerOrdersQuery.GetOrderDetails(_creditsQuery, order, _productsQuery.GetProducts()),
     }));
 }
Esempio n. 5
0
        public ActionResult Account(EmployerJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms)
        {
            try
            {
                // Process the post to check validations.

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

                joinModel.Prepare();
                joinModel.Validate();
                Save(new Login(), joinModel, acceptTerms != null && acceptTerms.IsChecked);

                if (acceptTerms != null && acceptTerms.IsChecked)
                {
                    // Check for an existing login.

                    if (_loginCredentialsQuery.DoCredentialsExist(new LoginCredentials {
                        LoginId = joinModel.JoinLoginId
                    }))
                    {
                        throw new DuplicateUserException();
                    }

                    // Go to the next page.

                    return(Next());
                }
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new NewOrderErrorHandler());
            }

            // Show the user the errors.

            var coupon = GetCoupon(Pageflow.CouponId);
            var order  = PrepareOrder(Pageflow.ContactProductId, coupon, Pageflow.UseDiscount, Pageflow.CreditCard);

            return(AccountView(order, null, joinModel, acceptTerms != null && acceptTerms.IsChecked));
        }
Esempio n. 6
0
        public ActionResult Account(Login loginModel, [Bind(Include = "RememberMe")] CheckBoxValue rememberMe, EmployerJoin join, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms)
        {
            try
            {
                // Try to process the login first.

                if (!loginModel.IsEmpty || (rememberMe != null && rememberMe.IsChecked))
                {
                    loginModel.RememberMe = rememberMe != null && rememberMe.IsChecked;
                    loginModel.Prepare();
                    loginModel.Validate();
                    Save(loginModel, new EmployerJoin(), false);
                }
                else if (!join.IsEmpty || acceptTerms.IsChecked)
                {
                    if (acceptTerms == null || !acceptTerms.IsChecked)
                    {
                        ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new NewOrderErrorHandler());
                    }

                    join.Prepare();
                    join.Validate();
                    Save(new Login(), join, acceptTerms != null && acceptTerms.IsChecked);

                    // Check for an existing login.

                    if (_loginCredentialsQuery.DoCredentialsExist(new LoginCredentials {
                        LoginId = join.JoinLoginId
                    }))
                    {
                        throw new DuplicateUserException();
                    }
                }

                // Go to the previous page.

                return(Previous());
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new NewOrderErrorHandler());
            }

            // Show the user the errors.

            var coupon = GetCoupon(Pageflow.CouponId);
            var order  = PrepareOrder(Pageflow.ContactProductId, coupon, Pageflow.UseDiscount, Pageflow.CreditCard);

            return(AccountView(order, loginModel, join, acceptTerms != null && acceptTerms.IsChecked));
        }
Esempio n. 7
0
 protected ActionResult TryJoin(EmployerJoin join, CheckBoxValue acceptTerms)
 {
     return(TryJoin(join, acceptTerms, () => new StandardErrorHandler()));
 }
Esempio n. 8
0
        private ActionResult Join(EmployerJoin join, CheckBoxValue acceptTerms)
        {
            var result = TryJoin(join, acceptTerms);

            return(result ?? AccountView(null, join, acceptTerms != null && acceptTerms.IsChecked));
        }
Esempio n. 9
0
 public ActionResult JoinJoin(EmployerJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms)
 {
     return(Join(joinModel, acceptTerms));
 }