public int PostGame(BoardSize bs) { var json = _jss.Serialize(bs); var enc = Encoding.ASCII; var ba = enc.GetBytes(json); WebRequest request = SetupRequest(Url + "/games", "POST", "application/json"); request.ContentLength = ba.Length; var stream = request.GetRequestStream(); stream.Write(ba, 0, ba.Length); stream.Close(); var resp = request.GetResponse(); resp.Close(); return 1; }
public int PostGame(BoardSize bs) { var json = _jss.Serialize(bs); var enc = Encoding.ASCII; var ba = enc.GetBytes(json); WebRequest request = SetupRequest(Url + "/games", "POST", "application/json"); request.ContentLength = ba.Length; var stream = request.GetRequestStream(); stream.Write(ba, 0, ba.Length); stream.Close(); var resp = request.GetResponse(); resp.Close(); return(1); }
private void BtnCreateClick(object sender, RoutedEventArgs e) { if (ValidateBoardSize()) { int vSize = int.Parse(txt_vSize.Text); int hSize = int.Parse(txt_hSize.Text); var bs = new BoardSize { Width = vSize, Height = hSize }; _api.PostGame(bs); lb_games.ItemsSource = GetGames(); btn_create.Content = "created"; var mainWindow = new MainWindow { GameId = lb_games.Items.Count, PlayerId = 1 }; mainWindow.Show(); } else { btn_create.Content = "not created"; } }