Esempio n. 1
0
        private void CreateUser(String email, String password, TravelAgencyService service, Action createUser)
        {
            List <String> errorList = new List <string>(1);
            bool          isSuccess = false;

            // Attempt to register the user
            if (WebDataHelper.CreateAccount(email, password, errorList))
            {
                try
                {
                    createUser();
                    service.Save();
                    WebSecurity.Login(email, password);
                    isSuccess = true;
                }
                catch (Exception ex)
                {
                    HandleRegistrationError(email, ex);
                }
            }
            else
            {
                ModelState.AddModelError("", "E-mail is already in use.");
            }
            // Warning: Redirect to URL throws special exception which must not be handled.
            // Whne it is handled in above try then the newly created account is deleted.
            if (isSuccess)
            {
                RedirectHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
        }
        private bool CreateAccount(RegistrationModel model)
        {
            List <String> erroList = new List <String>(1);
            var           res      = WebDataHelper.CreateAccount(model.RegisterData.Email, model.RegisterData.Password, erroList);

            erroList.ForEach(i => ModelState.AddModelError(String.Empty, i));
            return(res);
        }