예제 #1
0
 public ActionResult RoleCreate(roleModel role1, string UserName)
 {
     if (!Roles.RoleExists(role1.RoleName))
     {
         Roles.CreateRole(role1.RoleName);
     }
     Roles.AddUserToRole(UserName, role1.RoleName);
     return RedirectToAction("Index", "Home");
 }
예제 #2
0
        public ActionResult Register(RegisterModel model, roleModel role1)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);

                                                                    //from here username just registered is passed along.......
                    return RedirectToAction("RoleCreate", "Account", new { UserName = model.UserName });
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }