Ejemplo n.º 1
0
 public void ModifyPermission(ActionsDto permission)
 {
     var action = this._actionRepository.GetByKey(permission.ID);
     if (action != null)
     {
         action.Update(permission.Area, permission.Controller, permission.Action, permission.Description,
             permission.UpdatedBy);
         this._actionRepository.Update(action);
     }
 }
        public ActionResult EditPermission(ActionsDto model)
        {
            model.UpdatedBy = this.LoginUser.Identity.Name;
            try
            {
                using (var service = ServiceLocator.Instance.Resolve<IMenuPermissionService>())
                {
                    service.ModifyPermission(model);
                }
            }
            catch (Exception)
            {
                return Json(false, "Modify the permission failure.");
            }

            return Json(true);
        }
Ejemplo n.º 3
0
 public void CreatePermission(ActionsDto permission)
 {
     var action = new Actions(permission.Area, permission.Controller, permission.Action, permission.Description,
         permission.CreatedBy);
     this._actionRepository.Add(action);
 }
        public ActionResult AttachPermissionToRole(ActionsDto model, Guid[] roles)
        {
            var handler = this.LoginUser.Identity.Name;
            try
            {
                using (var service = ServiceLocator.Instance.Resolve<IMenuPermissionService>())
                {
                    service.AttachPermissionToRoles(model.ID, roles, handler);
                }
            }
            catch (Exception)
            {
                return Json(false, "Attach the permission to roles failure.");
            }

            return Json(true);
        }
        public ActionResult AttachPermissionToRole(Guid permissionId)
        {
            // find all roles.
            // find the roles that include to the permission.
            using (var roleService = ServiceLocator.Instance.Resolve<IRoleService>())
            using (var permissionService = ServiceLocator.Instance.Resolve<IMenuPermissionService>())
            {
                var roles = roleService.FindAllRoles();
                var rolesOfPermission = permissionService.FindRolesOfPermission(permissionId);

                ViewBag.Roles = roles;
                ViewBag.RolesOfPermission = rolesOfPermission;
                var model = new ActionsDto {ID = permissionId};
                return PartialView(model);
            }
        }