//must implement the add game to player in services too
        public void ADD_GAMEttoplayer(int pid)
        {
            int      newGameid = GettheMaxGameID() + 1;
            DateTime DT        = DateTime.Now.AddHours(0);

            GameT g = new GameT();

            g.Accuracy  = 50.0;
            g.Headshots = 120;
            g.IDPlayer  = pid;
            g.IDGame    = newGameid;
            g.Kills     = 100;
            g.Score     = 1337;
            g.Timestamp = DT.ToString();

            //RestClient restClient = new RestClient("http://24.61.47.62:1337");
            RestClient restClient = new RestClient("http://localhost:57759");
            string     postit     = "/Api/ARZAPIctrl/AddGameToPlayerID" + "/" + pid;


            var request = new RestRequest(postit, Method.POST);

            request.AddJsonBody(g);
            IRestResponse Ires = restClient.Execute(request);

            if (Ires.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //now the new max is TRIPid .. I should make a slef update function in MNGR
                Console.WriteLine("gamesent sent");
            }
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (StackAdd.Children.OfType <TextBox>().Any(x => x.Text == ""))
     {
         MessageBox.Show("Заполните все поля");
         return;
     }
     Game = ComboBoxGame.SelectedItem as GameT;
     if (!reg.IsMatch(Game.Score.ToString()))
     {
         MessageBox.Show("Введите счет в формате 2:5");
         return;
     }
     try
     {
         Game.Winner = ConverterToScore.Convert(Game.Score);
         Connection.NewInstance().SaveChanges();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         DataContext = null;
         Games       = Connection.NewInstance().GameT.ToList();
         Stadiums    = Connection.NewInstance().StadiumT.ToList();
         DataContext = this;
     }
 }
 public CreateGame()
 {
     reg = new Regex(@"^(\d{1,2}):(\d{1,2})$");
     InitializeComponent();
     Countries = Connection.NewInstance().CountryT.ToList();
     Stadiums  = Connection.NewInstance().StadiumT.ToList();
     Teams     = Connection.NewInstance().TeamT.ToList();
     Game      = new GameT()
     {
         Date = DateTime.Now
     };
     DataContext = this;
 }
Beispiel #4
0
 /// <summary>
 /// Stops the game and raises the <see cref="OnGameStops"/> event.
 /// </summary>
 public static void StopTheGame()
 {
     try
     {
         GameT.Abort();
     }
     catch (Exception e)
     {
     }
     finally
     {
         GameT = null;
     }
     BNOF     = 1;
     INTERVAL = 250;
     GameUI   = null;
     GameHandle.GameRuning = false;
     GameHandle.mapSize    = Size.Empty;
     GameHandle.snake      = null;
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Game = DeleteComboBox.SelectedItem as GameT;
         Connection.NewInstance().GameT.Remove(Game);
         Connection.NewInstance().SaveChanges();
     }
     catch
     {
         MessageBox.Show("Выберите игру для удаления");
     }
     finally
     {
         DataContext = null;
         Games       = Connection.NewInstance().GameT.ToList();
         DeleteComboBox.SelectedIndex = -1;
         DeleteComboBox.ItemsSource   = Games;
         DataContext = this;
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (StackAdd.Children.OfType <TextBox>().Any(x => x.Text == "") || StackAdd.Children.OfType <ComboBox>().Any(x => x.SelectedIndex < 0))
            {
                MessageBox.Show("Заполните все поля");
                return;
            }
            if (!reg.IsMatch(Game.Score.ToString()))
            {
                MessageBox.Show("Введите счет в формате 2:5");
                return;
            }
            Game.Winner = ConverterToScore.Convert(Game.Score);

            try
            {
                Connection.NewInstance().GameT.Add(Game);
                Connection.NewInstance().SaveChanges();
            }
            catch (Exception ex)
            {
                Connection.NewInstance().GameT.Remove(Game);
                MessageBox.Show(ex.Message, "Ошибка заполнения данных");
            }
            finally
            {
                DataContext = null;
                Countries   = Connection.NewInstance().CountryT.ToList();
                Stadiums    = Connection.NewInstance().StadiumT.ToList();
                Teams       = Connection.NewInstance().TeamT.ToList();
                Game        = new GameT()
                {
                    Date = DateTime.Now
                };;
                DataContext = this;
                StackAdd.Children.OfType <TextBox>().ToList().ForEach(tb => tb.Text           = String.Empty);
                StackAdd.Children.OfType <ComboBox>().ToList().ForEach(cb => cb.SelectedIndex = -1);
                DatePickerGame.Text = DateTime.Now.ToString();
            }
        }