Пример #1
0
        public async Task <IActionResult> DeletePermissionOnRole(RolePermissionRequest request)
        {
            //Recupero l'elemento dal business layer
            var entity = AuthorizationLayer.GetPermissionRole(request.PermissionId, request.RoleId);

            //Se l'utente non hai i permessi non posso rimuovere entità con userId nullo
            if (entity == null)
            {
                return(NotFound());
            }

            //Invocazione del service layer
            var validations = await AuthorizationLayer.DeletePermissionRole(entity, PlatformUtils.GetIdentityUserId(User));

            if (validations.Count > 0)
            {
                return(BadRequest(validations));
            }

            var permissions = AuthorizationLayer.FetchPermissionsOnRole(entity.RoleId);

            //Return contract
            return(Ok(permissions.As(ContractUtils.GenerateContract)));
        }