public ActionResult Index(string action, RoleInputModel[] list)
        {
            if (action == "new") return Create();
            if (action == "delete") return Delete(list);

            ModelState.AddModelError("", Resources.RoleController.InvalidAction);
            var vm = new RolesViewModel(UserManagementRepository);
            return View("Index", vm);
        }
        public ActionResult Create(RoleInputModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    UserManagementRepository.CreateRole(model.Name);
                    TempData["Message"] = Resources.RoleController.RoleCreated;
                    return RedirectToAction("Index");
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", Resources.RoleController.ErrorCreatingRole);
                }
            }

            return View("Create", model);
        }
        private ActionResult Delete(RoleInputModel[] list)
        {
            var query = from item in list
                        where item.Delete && !(item.CanDelete)
                        select item.Name;
            foreach(var name in query)
            {
                ModelState.AddModelError("", string.Format(Resources.RoleController.CannotDeleteRole, name));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    foreach (var item in list.Where(x=>x.Delete && x.CanDelete).Select(x=>x.Name))
                    {
                        UserManagementRepository.DeleteRole(item);
                    }
                    TempData["Message"] = Resources.RoleController.RolesDeleted;
                    return RedirectToAction("Index");
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", Resources.RoleController.ErrorDeletingRole);
                }
            }

            var vm = new RolesViewModel(UserManagementRepository);
            return View("Index", vm);
        }