public async Task <JObject> SetLightsAsync([FromBody] Light light) { try { if (light.Controller) { var context = new DatabaseContext(); context.Lights.Add(light); context.SaveChanges(); } else { var service = new MqttService(); GetLight newLight = new GetLight() { Animation = light.Animation, Brightness = light.Brightness, Color = light.Color }; await service.SendMessageAsync("boominator", JObject.FromObject(newLight).ToString()); } var value = "{ \"response\": \"success\" }"; return(JObject.Parse(value)); } catch (Exception e) { var value = "{ \"response\": \"error " + e.Message + "\" }"; return(JObject.Parse(value)); } }