public async Task<HttpResponseMessage> SenderCommand() { var jo = JObject.Parse(await this.Request.Content.ReadAsStringAsync()); var id = jo.SelectToken("$.deviceId").Value<String>(); JObject reason; if (Device<ISenderCommand>.CheckedCommand(jo.SelectToken("$.command").Value<JObject>(), out reason)) { using (ISenderCommand command = new Device<ISenderCommand>(id)) { command.SenderCommand(jo.SelectToken("$..command").ToString()); } return new HttpResponseMessage(HttpStatusCode.OK); } else { return new HttpResponseMessage(HttpStatusCode.BadRequest) { RequestMessage = Request, Content = new StringContent(reason.ToString()) }; } }