コード例 #1
0
        public ActionResult Join(AccountSignupVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var accountExists = accountManager.DoesAccountExist(model.Email);
                    if (!accountExists)
                    {
                        var newUser = new UserAccountDto {
                            EmailAddress = model.Email, Name = model.Name, Password = model.Password
                        };
                        var userSession = accountManager.CreateUserAccount(newUser);

                        if (userSession.UserId > 0)
                        {
                            SetUserIDToSession(userSession);
                        }

                        if (!String.IsNullOrEmpty(model.ReturnUrl))
                        {
                            return(RedirectToAction("joinmyteam", "users", new { id = model.ReturnUrl }));
                        }

                        return(RedirectToAction("accountcreated"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Account already exists with this email address");
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            return(View(model));
        }