private DigitalInputViewDTO MapInputUpdateToView(int pin, DigitalInputUpdateDTO input)
 {
     return(new DigitalInputViewDTO()
     {
         pin = pin, state = input.state
     });
 }
 public DigitalInputViewDTO SetInput(int pin, DigitalInputUpdateDTO input)
 {
     CheckOutOfBounds(pin);
     if (!(input.toggle == true))
     {
         inputs[pin] = MapInputUpdateToView(pin, input);
     }
     return(inputs[pin]);
 }
 public async Task <IActionResult> Put(int pin, [FromBody] DigitalInputUpdateDTO update)
 {
     try
     {
         return(Ok(_service.SetInput(pin, update)));
     }
     catch (HttpException exc)
     {
         if (exc.Code == 400)
         {
             return(NotFound(exc.Message));
         }
         else
         {
             return(StatusCode(500));
         }
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }