BurningPlage.Controllers.AccountController.Register C# (CSharp) Метод

Register() публичный Метод

public Register ( string username, string email, string password, string confirmPassword ) : System.Web.Mvc.ActionResult
username string
email string
password string
confirmPassword string
Результат System.Web.Mvc.ActionResult
        public ActionResult Register(string username, string email, string password, string confirmPassword)
        {
            ViewData["Title"] = "Register";
            ViewData["PasswordLength"] = Provider.MinRequiredPasswordLength;

            // Non-POST requests should just display the Register form
            if (Request.HttpMethod != "POST")
            {
                return View();
            }

            // Basic parameter validation
            List<string> errors = new List<string>();

            if (String.IsNullOrEmpty(username))
            {
                errors.Add("You must specify a username.");
            }
            if (String.IsNullOrEmpty(email))
            {
                errors.Add("You must specify an email address.");
            }
            if (password == null || password.Length < Provider.MinRequiredPasswordLength)
            {
                errors.Add(String.Format(CultureInfo.InvariantCulture,
                         "You must specify a password of {0} or more characters.",
                         Provider.MinRequiredPasswordLength));
            }
            if (!String.Equals(password, confirmPassword, StringComparison.Ordinal))
            {
                errors.Add("The password and confirmation do not match.");
            }

            if (errors.Count == 0)
            {

                // Attempt to register the user
                MembershipCreateStatus createStatus;
                MembershipUser newUser = Provider.CreateUser(username, password, email, null, null, true, null, out createStatus);

                if (newUser != null)
                {

                    FormsAuth.SetAuthCookie(username, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    errors.Add(ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            ViewData["errors"] = errors;
            ViewData["username"] = username;
            ViewData["email"] = email;
            return View();
        }