public void CloseTurn()
        {
            try
            {
                Dictionary <string, string> dict = new Dictionary <string, string>();
                TurnAggregationModel        tmp  = new TurnAggregationModel
                {
                    Date = _output[1].MatchDate, WinnerName = ShowStandings()[0].Name
                };
                dict.Add("matchups", "");
                foreach (var elem in _output)
                {
                    dict["matchups"] = dict["matchups"] + ";" + elem.Player1 + "," + elem.Player2 + "," + elem.Winner;
                }

                tmp.Matches = JsonConvert.SerializeObject(dict);
                _context.Turns.Add(tmp);

                _output.Clear();
                foreach (var elem in _context.Players.ToList())
                {
                    elem.GeneralGamesWon  += elem.GamesWon;
                    elem.GeneralGamesLost += elem.GamesLost;
                    elem.GamesWon          = 0;
                    elem.GamesLost         = 0;
                }
                _context.SaveChanges();
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("No matchups!");
            }
        }
Пример #2
0
        public void DeleteLeague(string name)
        {
            foreach (var elem in _context.Leagues.ToList())
            {
                if (elem.Name == name)
                {
                    _context.Leagues.Remove(elem);
                }
            }

            _context.SaveChanges();
            MessageBox.Show("League deleted!");
        }
Пример #3
0
        public void AddPlayer(string name, int score, string desc)
        {
            AchievementModel model = new AchievementModel {
                Name = name, Score = score, Description = desc
            };

            _context.Achievements.Add(model);
            _context.SaveChanges();
            MessageBox.Show("Added!");
        }
Пример #4
0
        public void AddPlayer(string name)
        {
            PlayerModel tmp = new PlayerModel {
                Name = name, Elo = 1600
            };

            _context.Players.Add(tmp);
            _context.SaveChanges();
            MessageBox.Show("Added Player: " + name);
        }
        public void Submit(DateTime startDate, string name)
        {
            LeagueModel league = new LeagueModel();
            Dictionary <string, string> list = new Dictionary <string, string>();

            list.Add("players", _playersString);
            var players = JsonConvert.SerializeObject(list);

            league.StartDate   = startDate;
            league.Competitors = players;
            league.Name        = name;
            _context.Leagues.Add(league);
            _context.SaveChanges();
            MessageBox.Show("League added!");
        }
Пример #6
0
        public void Edit(string player, string name, string elo)
        {
            foreach (var elem in _context.Players.ToList())
            {
                if (elem.Name != player)
                {
                    continue;
                }
                if (name != Empty)
                {
                    elem.Name = name;
                }

                if (elo != Empty)
                {
                    elem.Elo = Convert.ToInt32(elo);
                }
            }

            _context.SaveChanges();
            MessageBox.Show("Done");
        }