/// <summary> /// </summary> /// <exception cref="FormatException"/> /// <param name="queryObject"></param> /// <returns></returns> public async Task <IPayload> GetAllDevices(QueryObject queryObject) { var devices = await _context.Devices .ApplyQuery(queryObject, out int totalItems) .Select(device => _mapper.Map <DeviceDto>(device)) .ToListAsync() .ConfigureAwait(false); var factory = new CollectionPayloadFactory <DeviceDto>(devices, queryObject, totalItems); return(factory.GetPayload()); }
async Task <IPayload> IGatewayService.GetAllGateways(QueryObject queryObject) { List <GatewayDto> gateways = await _context.Gateways .Include(gateway => gateway.Devices) .ApplyQuery(queryObject, out int totalItems) .Select(gateway => _mapper.Map <GatewayDto>(gateway)) .ToListAsync() .ConfigureAwait(false); var factory = new CollectionPayloadFactory <GatewayDto>(gateways, queryObject, totalItems); return(factory.GetPayload()); }