Esempio n. 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (account.Money < decimal.Parse(tbValueBet.Text))
            {
                MessageBox.Show("Not enough money to make bet");
                return;
            }
            if (decimal.Parse(tbValueBet.Text) < 3)
            {
                MessageBox.Show("Minimal value of bet = 3");
                return;
            }
            using (MainDB db = new MainDB())
            {
                db.Accounts.Attach(account);
                account.Money -= decimal.Parse(tbValueBet.Text);
                var        coefID = (dgMatchCoefs.SelectedItem as Coeficient).ID;
                Coeficient cf     = db.Coefs.FirstOrDefault(x => x.ID == coefID);
                // db.Entry(cf).State = System.Data.Entity.EntityState.Unchanged;
                UserBet ub = new UserBet()
                {
                    Accounts = account, Coef = cf,
                    Price    = double.Parse(tbValueBet.Text)
                };

                db.UserBets.Add(ub);
                db.SaveChanges();
            }

            MessageBox.Show("Bet made!");
            this.Close();
        }
Esempio n. 2
0
 private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
 {
     using (MainDB db = new MainDB())
     {
         lbMatches.ItemsSource = db.Matches.Include("TeamHome").Include("TeamAway").ToList();
     }
 }
Esempio n. 3
0
 public void GetBets()
 {
     using (MainDB db = new MainDB())
     {
         db.Accounts.Attach(account);
         lbUserBets.ItemsSource = account.Bets.ToList();
     }
 }
Esempio n. 4
0
 private void LbLeagues_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     using (MainDB db = new MainDB())
     {
         var t = db.Matches.ToList().Where(x => x.TeamHome.League.Equals(lbLeagues.SelectedItem as League));
         lbMatches.ItemsSource = t;
     }
     //lbMatches.ItemsSource = tmp;
 }
Esempio n. 5
0
        public MatchWindow(Match match, Accounts acc)
        {
            InitializeComponent();
            MainGrid.Visibility = Visibility.Hidden;

            account = acc;
            using (MainDB db = new MainDB())
            {
                db.Matches.Attach(match);
                this.Title = match.TeamHome.Name + " - " + match.TeamAway.Name;
                dgMatchCoefs.ItemsSource = match.Coefs;
            }
        }
Esempio n. 6
0
        public MainWindow(Accounts acc)
        {
            InitializeComponent();

            account             = acc;
            AccCard.DataContext = account;
            using (MainDB db = new MainDB())
            {
                lbMatches.ItemsSource = db.Matches.Include("TeamHome").Include("TeamAway").ToList();
                lbLeagues.ItemsSource = db.Leagues.ToList();
            }

            RefreshAccCard(acc);
        }
Esempio n. 7
0
        private void Login_btn_OnClick(object sender, RoutedEventArgs e)
        {
            using (MainDB db = new MainDB())
            {
                Accounts acc = db.Accounts.FirstOrDefault(x => x.Email == Login.Text);
                if (acc == null)
                {
                    MessageBox.Show("Login not found");
                    //return;
                }

                MainWindow mw = new MainWindow(acc);

                if (acc.Password == Pass.Password)
                {
                    this.Close();
                    mw.Show();
                }
                else
                {
                    MessageBox.Show("Password is in corrected");
                }
            }
        }