public void SetColorOfGroup(HttpContext context, string groupId) { if (context.Request.Payload.Length > 0) { string json = context.Request.Payload.ReadAll(); RgbValue rgbValue = JsonSerializer.DeserializeJson <RgbValue>(json); int id = ApiBase.ParseId(groupId); if (rgbValue == null) { throw new BadRequestException(BadRequestException.MSG_INVALID_PAYLOAD); } _groupHandler.SetColorOfGroup(id, rgbValue.Rgb); context.Response.Status = HttpStatus.OK; } else { throw new BadRequestException(BadRequestException.MSG_PAYLOAD_EXPECTED); } }
public void SetLedsOfGroup(HttpContext context, string groupId) { if (context.Request.Payload.Length > 0) { string json = context.Request.Payload.ReadAll(); GroupLeds groupLeds = JsonSerializer.DeserializeJson <GroupLeds>(json); int id = ApiBase.ParseId(groupId); if (groupLeds == null) { throw new BadRequestException(BadRequestException.MSG_INVALID_PAYLOAD); } _groupHandler.SetLedsOfGroup(id, groupLeds); GroupLeds response = _groupHandler.GetGroupLeds(id); string jsonRespone = JsonSerializer.SerializeJson(groupLeds); context.Response.Payload.Write(jsonRespone); context.Response.Status = HttpStatus.OK; } else { throw new BadRequestException(BadRequestException.MSG_PAYLOAD_EXPECTED); } }