public ActionResult AddAccount(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                MembershipService.CreateUser(model.UserName, model.Password, model.Email);
                Roles.AddUserToRole(model.UserName, "user");
            }

            return View(model);
        }
        public ActionResult DangKy(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                    if (createStatus == MembershipCreateStatus.Success)
                    {
                        if (!Roles.RoleExists("user"))
                        {
                            Roles.CreateRole("user");
                        }
                        Roles.AddUserToRole(model.UserName, "user");
                        FormsService.SignIn(model.UserName, createPersistentCookie: false);
                        return RedirectToAction("Index", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                    }

                    return RedirectToAction("Index", "Home");

                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            ViewBag.PasswordLength = MembershipService.MinPasswordLength;
            return View(model);
        }