示例#1
0
        /// <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());
        }
示例#2
0
        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());
        }