public async Task <OperationDataResult <InnerResourcesModel> > Index(InnerResourceRequestModel requestModel) { try { var innerResourcesModel = new InnerResourcesModel(); var query = _dbContext.InnerResources .Where(x => x.WorkflowState != Constants.WorkflowStates.Removed) .AsNoTracking() .AsQueryable(); query = QueryHelper.AddSortToQuery(query, requestModel.Sort, requestModel.IsSortDsc); innerResourcesModel.Total = await query.Select(x => x.Id).CountAsync(); query = query .Skip(requestModel.Offset) .Take(requestModel.PageSize); innerResourcesModel.InnerResourceList = await query .Select(x => new InnerResourceModel { Name = x.Name, Id = x.Id, ExternalId = x.ExternalId, RelatedOuterResourcesIds = _dbContext.OuterInnerResources.Where(y => y.InnerResourceId == x.Id && y.WorkflowState != Constants.WorkflowStates.Removed).Select(z => z.OuterResourceId).ToList() }).ToListAsync(); innerResourcesModel.Name = _dbContext.PluginConfigurationValues .FirstOrDefault(x => x.Name == "OuterInnerResourceSettings:InnerResourceName") ?.Value; return(new OperationDataResult <InnerResourcesModel>(true, innerResourcesModel)); } catch (Exception e) { Trace.TraceError(e.Message); _logger.LogError(e.Message); return(new OperationDataResult <InnerResourcesModel>(false, _localizationService.GetString("ErrorObtainInnerResources"))); } }
public async Task <OperationDataResult <InnerResourcesModel> > GetAllMachines(InnerResourceRequestModel requestModel) { return(await _innerResourceService.Index(requestModel)); }