Esempio n. 1
0
        public async Task <ActionResultResponse> UpdateRolePagePermission(string tenantId, string roleId, int pageId, int permissions)
        {
            var roleInfo = await _roleRepository.FindByIdAsync(roleId, new CancellationToken());

            if (roleInfo == null)
            {
                return(new ActionResultResponse(-1, _resourceService.GetString("Role does not exists.")));
            }

            if (roleInfo.TenantId != tenantId)
            {
                return(new ActionResultResponse(-403, _sharedResourceService.GetString("You do not have permission to do this action.")));
            }

            var result = await _rolePageRepository.UpdatePermission(roleId, pageId, permissions);

            return(new ActionResultResponse(result,
                                            result < 0
                    ? _sharedResourceService.GetString("Something went wrong. Please contact with administrator.")
                    : result == 0
                        ? _resourceService.GetString("Please select permission for update.")
                        : _resourceService.GetString("Update permission successful.")));
        }