Пример #1
0
        public async Task <GetGatewayDatapointsResponse> Handle(GetGatewayDatapointsRequest message)
        {
            var gatewayResponse = await GetGateway(message.Id.ToString());

            if (gatewayResponse.StatusCode == HttpStatusCode.NotFound)
            {
                return(new GetGatewayDatapointsResponse()
                {
                    ErrorModel = new ErrorModel(ErrorType.NotFound)
                });
            }

            var gatewaySettingsResponse = await GetGatewaySettings(message.Id.ToString());

            if (gatewaySettingsResponse.StatusCode == HttpStatusCode.NotFound)
            {
                return(new GetGatewayDatapointsResponse()
                {
                    ErrorModel = new ErrorModel(ErrorType.NotFound)
                });
            }

            var kolibriResponse = await ReadValuesFromKolibri(gatewaySettingsResponse.Data.Select(x => x.HexAdress));

            var datapoints = AssignValues(gatewaySettingsResponse.Data, kolibriResponse.Data);

            var response = new GetGatewayDatapointsResponse()
            {
                Data = datapoints
            };

            return(response);
        }
Пример #2
0
        public async Task <IHttpActionResult> GetDatapoints([FromUri] int id)
        {
            var request = new GetGatewayDatapointsRequest()
            {
                Id = id
            };

            var responseModel = await this.getDatapointsHandler.Handle(request);

            return(this.CreateHttpActionResult(responseModel));
        }