private DigitalOutputUpdateEntity MapPUTDTOtoEntity(DigitalOutputUpdateDTO outputPin)
 {
     return(new DigitalOutputUpdateEntity()
     {
         state = outputPin.state == true ? "ON" : "OFF",
         toggle = outputPin.toggle
     });
 }
 public async Task <IActionResult> Put(int id, [FromBody] DigitalOutputUpdateDTO content)
 {
     // DigitalOutputUpdateDTO content = new DigitalOutputUpdateDTO(){pin=1,state=true};
     try{
         return(Ok(await _service.UpdateOutputAsync(id, content)));
     }
     catch
     {
         return(StatusCode(500));
     }
 }
        public async Task <DigitalOutputViewDTO> UpdateOutputAsync(int pin, DigitalOutputUpdateDTO outputPin)
        {
            var baseUrl = _configuration["ioDeviceBaseURI"];
            DigitalOutputViewDTO result = null;

            string internalResult = null;

            // the body for the put call

            var messageBody = MapPUTDTOtoEntity(outputPin);

            internalResult = await CallDevicePut(baseUrl, $"/io/out/{pin.ToString()}", messageBody);

            var formatedResult = JsonConvert.DeserializeObject <DigitalOutputViewEntity>(internalResult);

            result = FormatOutputViewEntityToDTOEntity(formatedResult);

            return(result);
        }