public ActionResult RegisterAdmin(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the new admin user
                MembershipCreateStatus createStatus;
                MembershipUser user = Membership.GetUser(model.UserName);
                if (user == null)
                {
                    Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
                }
                else
                {
                    createStatus = MembershipCreateStatus.DuplicateUserName;
                }

                if (createStatus == MembershipCreateStatus.Success || createStatus == MembershipCreateStatus.DuplicateUserName)
                {
                    // The very first user who register’s is a Dev
                    // Devs and Admins can register further Admins.
                    if (!Roles.RoleExists("Admin")) Roles.CreateRole("Admin");

                    Roles.AddUserToRole(model.UserName, "Admin");

                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

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

                if (createStatus == MembershipCreateStatus.Success)
                {
                    // The very first user who register’s is a DEV
                    // Subsequent registrations are Admins and no roles
                    if (!Roles.RoleExists("Dev"))
                    {
                        Roles.CreateRole("Dev");
                        Roles.AddUserToRole(model.UserName, "Dev");
                    }

                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

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