コード例 #1
0
 public void SetLeds(HttpContext context, string controllerId)
 {
     if (context.Request.Payload.Length > 0)
     {
         int      id       = ApiBase.ParseId(controllerId);
         string   json     = context.Request.Payload.ReadAll();
         RgbValue rgbValue = JsonSerializer.DeserializeJson <RgbValue>(json);
         if (rgbValue != null)
         {
             _controllerHandler.SetColor(id, rgbValue.Rgb);
             context.Response.Status = HttpStatus.OK;
         }
         else
         {
             throw new BadRequestException(BadRequestException.MSG_INVALID_PAYLOAD);
         }
     }
     else
     {
         throw new BadRequestException(BadRequestException.MSG_PAYLOAD_EXPECTED);
     }
 }