public async Task <ApiResult <GetAllIndustryOutput> > GetAll([FromUri] GetAllIndustryInput input, CancellationToken cancelToken) { if (Authorization == null) { return(new ApiResult <GetAllIndustryOutput>(APIResultCode.Unknown, new GetAllIndustryOutput { }, APIResultMessage.TokenNull)); } var user = _tokenManager.GetUser(Authorization); if (user == null) { return(new ApiResult <GetAllIndustryOutput>(APIResultCode.Unknown, new GetAllIndustryOutput { }, APIResultMessage.TokenError)); } if (input.PageIndex < 1) { input.PageIndex = 1; } if (input.PageSize < 1) { input.PageSize = 10; } int startRow = (input.PageIndex - 1) * input.PageSize; var data = await _industryRepository.GetAllIncludeAsync(new IndustryDto { Name = input?.Name, BuildingId = input?.BuildingId, BuildingUnitId = input?.BuildingUnitId, OperationUserSmallDistrictId = user.SmallDistrictId }, cancelToken); var listCount = data.Count(); var list = data.OrderByDescending(x => x.CreateOperationTime).Skip(startRow).Take(input.PageSize); return(new ApiResult <GetAllIndustryOutput>(APIResultCode.Success, new GetAllIndustryOutput { List = list.Select(x => new GetIndustryOutput { Id = x.Id.ToString(), Name = x.Name, Acreage = x.Acreage, BuildingId = x.BuildingUnit.BuildingId.ToString(), Oriented = x.Oriented, BuildingName = x.BuildingUnit.Building.Name, BuildingUnitId = x.BuildingUnitId.ToString(), BuildingUnitName = x.BuildingUnit.UnitName, NumberOfLayers = x.NumberOfLayers }).ToList(), TotalCount = listCount })); }