Пример #1
0
        public ActionResult Register(RegisterModel model, string returnUrl, FormCollection form)
        {
            if (_workContext.CurrentAccount == null || _workContext.CurrentAccount.IsRegistered())
            {
                //Already registered customer. 
                _authenticationService.SignOut();
              
                //Save a new record
               // _workContext.CurrentAccount = _accountService.InsertGuestAccount();
            }

            var account = new Account(){
                  Birthdate = model.Birthdate,
                  Contact = model.Contact,
                Country= model.Country,
                  Email = model.Email,
                   Deleted = false,
                   Gender = model.Gender,
                   Language = model.Language,
                   CreatedOnUtc = DateTime.Now,
                   LastActivityDateUtc = DateTime.Now,
                   AccountGuid = Guid.NewGuid()

                   
            };

            
            if (ModelState.IsValid)
            {
                 
                   var registrationRequest = new AccountRegistrationRequest(account, model.Email, model.Password, PasswordFormat.Hashed);
               // _accountService.InsertGuestAccount
                var registrationResult = _accountRegistrationService.RegisterAccount(registrationRequest);
                if (registrationResult.Success)
                { _accountService.CreateAccount(account);
                  
                    _authenticationService.SignIn(account, true);
                    return RedirectToRoute("HomePage");
                }
                else
                {
                    foreach (var error in registrationResult.Errors)
                        ModelState.AddModelError("", error);
                }
            }
            return View(model);
        }
Пример #2
0
 //[HttpsRequirement(SslRequirement.Yes)]
 public ActionResult Register()
 {
     var model = new RegisterModel();
     return View(model);
 }