Exemple #1
0
        public ActionResult NewRole()
        {
            RoleModel model = new RoleModel()
             {
            Role = new Role(),
            AllRights = userService.GetAllRights()
             };

             return View("NewRole", model);
        }
Exemple #2
0
        public ActionResult Create(int id, string name, int[] rightIds)
        {
            Role role = new Role();
             role.Site = Context.ManagedSite;

             try
             {
            UpdateModel(role, new[] { "Name" });

            if (rightIds != null && rightIds.Length > 0)
            {
               IList<Right> rights = userService.GetRightsByIds(rightIds);
               foreach (Right right in rights)
               {
                  log.DebugFormat("RightId {0}", right.Id);
                  role.Rights.Add(right);
               }
            }

            userService.UpdateRole(role);

            // Show the confirmation message
            MessageModel message = new MessageModel
            {
               Text = "Role created successfully!",
               Icon = MessageModel.MessageIcon.Info,
               CssClass = "margin-topbottom",
               IsClosable = true
            };
            RegisterMessage(message, true);

            return RedirectToAction("Index");
             }
             catch (Exception ex)
             {
            log.Error("RolesController.Create", ex);

            MessageModel message = new MessageModel
            {
               Text = GlobalResource("Message_GenericError"),
               Icon = MessageModel.MessageIcon.Alert,
               CssClass = "margin-topbottom"
            };
            RegisterMessage(message);
             }

             RoleModel model = new RoleModel()
             {
            Role = userService.GetRoleById(id),
            AllRights = userService.GetAllRights()
             };

             return View("NewRole", model);
        }
Exemple #3
0
        public ActionResult Edit(int id)
        {
            RoleModel model = new RoleModel()
                              {
                                 Role = userService.GetRoleById(id),
                                 AllRights = userService.GetAllRights()
                                                .OrderBy(r => r.RightGroup)
                                                .ThenBy(r => r.Name)
                                                .ToList()
                              };

             return View("Edit", model);
        }