public ActionResult Insert(RoleManagerViewModel model)
 {
     model.Roles.RemoveAll(r => string.IsNullOrEmpty(r));
     Roles.CreateRole(model.Roles.Last());
     //return RedirectToAction("Index");
     return View("Form", model);
 }
 public ActionResult Index()
 {
     var model = new RoleManagerViewModel
     {
         Roles = Roles.GetAllRoles().ToList()
     };
     return View(model);
 }
 public ActionResult Delete(RoleManagerViewModel model)
 {
     model.Roles.RemoveAll(r => String.IsNullOrEmpty(r));
     var role = model.Roles[model.Index];
     try
     {
         Roles.DeleteRole(role);
     }
     catch (Exception ex)
     {
         this.ModelState.AddModelError("", ex.Message);
         return View("Index", model);
     }
     return RedirectToAction("Index");
 }
        public ActionResult Change(RoleManagerViewModel model)
        {
            var roleToAdd = model.Roles[model.Index];
            var roleToRemove = Roles.GetAllRoles()[model.Index];
            Roles.CreateRole(roleToAdd);

            var users = Roles.GetUsersInRole(roleToRemove);
            foreach (var username in users)
            {
                Roles.RemoveUserFromRole(username, roleToRemove);
                Roles.AddUserToRole(username, roleToAdd);
            }
            Roles.DeleteRole(roleToRemove);
            return RedirectToAction("Index");
        }
        public ActionResult Change(RoleManagerViewModel model)
        {
            model.Roles.RemoveAll(r => string.IsNullOrEmpty(r));
            var roleToAdd = model.Roles[model.Index];
            var roleToRemove = Roles.GetAllRoles()[model.Index];
            Roles.CreateRole(roleToAdd);

            var users = Roles.GetUsersInRole(roleToRemove);
            foreach (var username in users)
            {
                Roles.RemoveUserFromRole(username, roleToRemove);
                Roles.AddUserToRole(username, roleToAdd);
            }
            Roles.DeleteRole(roleToRemove);
            //return RedirectToAction("Index");
            return View("Form", model);
        }
 public ActionResult ChangeMode(RoleManagerViewModel model)
 {
     model.Roles.RemoveAll(r => String.IsNullOrEmpty(r));
     return View("Form", model);
 }
 public ActionResult ChangeMode(RoleManagerViewModel model)
 {
     model.Roles.RemoveAll()
     return View("Index", model);
 }
 public ActionResult Insert(RoleManagerViewModel model)
 {
     Roles.CreateRole(model.Roles.Last());
     return RedirectToAction("Index");
 }