コード例 #1
0
        public GlobalPermissionForRole CheckExists(GlobalPermissionForRole permissionForRole)
        {
            if (permissionForRole.Permission != null && permissionForRole.MembershipRole != null)
            {
                return Get(permissionForRole.Permission.Id, permissionForRole.MembershipRole.Id);
            }

            return null;
        }
コード例 #2
0
        private static PermissionForRole MapGlobalPermission(GlobalPermissionForRole gp)
        {
            var pfr = new PermissionForRole
            {
                IsTicked       = gp.IsTicked,
                MembershipRole = gp.MembershipRole,
                Permission     = gp.Permission
            };

            return(pfr);
        }
コード例 #3
0
        public void UpdateOrCreateNew(GlobalPermissionForRole globalPermissionForRole)
        {
            // Firstly see if this exists already
            var permission = CheckExists(globalPermissionForRole);

            // if it exists then just update it
            if (permission != null)
            {
                permission.IsTicked = globalPermissionForRole.IsTicked;
            }
            else
            {
                Add(globalPermissionForRole);
            }
        }
コード例 #4
0
        public void UpdatePermission(AjaxEditPermissionViewModel ajaxEditPermissionViewModel)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    if (Request.IsAjaxRequest())
                    {
                        if (ajaxEditPermissionViewModel.Category == Guid.Empty)
                        {
                            // If category is empty guid then this is a global permission

                            var gpr = new GlobalPermissionForRole
                            {
                                MembershipRole =
                                    _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole),
                                Permission =
                                    _permissionService.Get(ajaxEditPermissionViewModel.Permission),
                                IsTicked = ajaxEditPermissionViewModel.HasPermission
                            };
                            _globalPermissionForRoleService.UpdateOrCreateNew(gpr);
                        }
                        else
                        {
                            // We have a category so it's a category permission 

                            var mappedItem = new CategoryPermissionForRole
                            {
                                Category = _categoryService.Get(ajaxEditPermissionViewModel.Category),
                                MembershipRole =
                                    _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole),
                                Permission =
                                    _permissionService.Get(ajaxEditPermissionViewModel.Permission),
                                IsTicked = ajaxEditPermissionViewModel.HasPermission
                            };
                            _categoryPermissionForRoleService.UpdateOrCreateNew(mappedItem);   
                        }
                    }
                    unitOfWork.Commit();
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    LoggingService.Error(ex);
                    throw;
                }
            }
        }
コード例 #5
0
 public void Delete(GlobalPermissionForRole permissionForRole)
 {
     _context.GlobalPermissionForRole.Remove(permissionForRole);
 }
コード例 #6
0
 public GlobalPermissionForRole Add(GlobalPermissionForRole permissionForRole)
 {
     return _context.GlobalPermissionForRole.Add(permissionForRole);
 }
コード例 #7
0
 public void Delete(GlobalPermissionForRole permissionForRole)
 {
     _globalPermissionForRoleRepository.Delete(permissionForRole);
 }
コード例 #8
0
 public void Add(GlobalPermissionForRole permissionForRole)
 {
     _globalPermissionForRoleRepository.Add(permissionForRole);
 }
コード例 #9
0
 public void Add(GlobalPermissionForRole permissionForRole)
 {
     _context.GlobalPermissionForRole.Add(permissionForRole);
 }