public bool SendText(MachineSendTextCommand command) { var cmd = new MachineCommand() { Type = "ShowText", Payload = command.Text }; Console.WriteLine($"Trying to send {JsonConvert.SerializeObject(cmd)} to {this.url}"); return(this.SendRequest(cmd).Result); }
private async Task <bool> SendRequest(MachineCommand command) { try{ var client = new HttpClient(); var result = await client.PostAsync(url, new StringContent(JsonConvert.SerializeObject(command), Encoding.UTF8, "application/json")); return(result.StatusCode == HttpStatusCode.OK); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
private string GetDesc(int x, int y) { MachineCommand cmd = GetCmd(x, y); return(cmd == null ? "" : cmd.CommandName); }
public MoneyController(ISodaMachineDbService sodaMachineDbService) { _machineCommand = new MachineCommand(sodaMachineDbService.GetDBContext().SodaMachines.First()); _dbService = sodaMachineDbService; }