Example #1
0
        public async Task <IActionResult> Post(InsertReadValueRequest model)
        {
            await _readValueService.Insert(model);

            return(Ok(new
            {
                success = true
            }));
        }
        public async Task <IActionResult> Post([FromBody] InsertReadValueRequest model)
        {
            try
            {
                var connection = new HubConnectionBuilder()
                                 .WithUrl(_configuration["ReadValuesHub"])
                                 .Build();

                connection.On(model.DeviceId.ToString(), (string deviceId, string value) =>
                              { });
                await connection.StartAsync();

                await connection.InvokeAsync("SendMessage", model.DeviceId.ToString(), model.Value.ToString());
            }
            catch (Exception)
            { }

            await _readValueService.Insert(model);

            return(Ok(new
            {
                success = true
            }));
        }