Пример #1
0
        public DataResult <int> CreatePermission(ResourcePermissionModel permissionModel)
        {
            var permission = new ResourcePermissionEntity
            {
                ResourceId         = permissionModel.ResourceId,
                ResourceTypeAction = m_permissionUoW.LoadPermissionTypeActionById(permissionModel.ResourceTypeAction.Id)
            };

            try
            {
                var result = m_permissionUoW.CreatePermission(permission);
                return(Success(result));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <int>(e.Message));
            }
        }
Пример #2
0
        public DataResult <bool> UpdatePermission(int id, ResourcePermissionModel permissionModel)
        {
            var permission = new ResourcePermissionEntity
            {
                ResourceId         = permissionModel.ResourceId,
                ResourceTypeAction = m_permissionUoW.LoadPermissionTypeActionById(permissionModel.ResourceTypeAction.Id)
            };

            try
            {
                m_permissionUoW.UpdatePermission(id, permission);
                return(Success(true));
            }
            catch (NoResultException <ResourcePermissionEntity> e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(m_translator.Translate("invalid-permission-id"), DataResultErrorCode.PermissionNotExistId));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(e.Message));
            }
        }
 private string FormatPermissionClaim(ResourcePermissionModel resourcePermission)
 {
     return(string.Format("{0}:{1}:{2}", resourcePermission.ResourceTypeAction.ResourcePermissionType.Name,
                          resourcePermission.ResourceId, resourcePermission.ResourceTypeAction.Name));
 }