示例#1
0
        public void UpdateMatchup(MatchupModel model)
        {
            //spMatchups_Update
            //@ID int,
            //@WinnerID int
            using (IDbConnection connection = new SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@ID", model.Id);
                p.Add("@WinnerID", model.Winner?.Id);

                connection.Execute("dbo.spMatchups_Update", p, commandType: CommandType.StoredProcedure);

                //dbo.spMatchupEntries_Update
                //@ID int,
                //@TeamCompetingID int = null,
                //@Score float null

                foreach (MatchupEntryModel me in model.Entries)
                {
                    if (me.TeamCompeting != null)
                    {
                        p = new DynamicParameters();
                        p.Add("@ID", me.Id);
                        p.Add("@TeamCompetingID", me.TeamCompeting.Id);
                        p.Add("@Score", me.Score);

                        connection.Execute("dbo.spMatchupEntries_Update", p, commandType: CommandType.StoredProcedure);
                    }
                }
            }
        }
示例#2
0
        public void UpdateMatchupScore(MatchupModel model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.GetConnectionString("WISGScoringDB")))
            {
                // dbo.spMatchups_UpdateWinnerId, @Id, @WinnerId
                var p = new DynamicParameters();
                p.Add("@Id", model.Id);
                if (!model.Draw)
                {
                    p.Add("@WinnerId", model.Winner.Id);
                }

                p.Add("@Draw", model.Draw);
                p.Add("@IsScored", model.IsScored);

                connection.Execute("dbo.spMatchups_UpdateWinnerId", p, commandType: CommandType.StoredProcedure);

                // dbo.spMatchupEntries_Update Id, TeamCompetingId, Score
                foreach (MatchupEntryModel me in model.Entries)
                {
                    p = new DynamicParameters();
                    p.Add("@Id", me.Id);
                    p.Add("@TeamCompetingId", me.TeamCompeting.Id);
                    p.Add("@Score", me.Score);
                    p.Add("@GamePoints", me.GamePoints);

                    connection.Execute("dbo.spMatchupEntries_Update", p, commandType: CommandType.StoredProcedure);
                }
            }
        }
示例#3
0
        public static List <MatchupModel> ConvertToMatchupModels(this List <string> lines)
        {
            List <MatchupModel> output = new List <MatchupModel>();

            foreach (string line in lines)
            {
                //id-0,entires=1,winner=2,matchupround=3
                string[] cols = line.Split(',');//adapting data from file

                MatchupModel matchup = new MatchupModel();
                matchup.Id      = int.Parse(cols[0]);
                matchup.Entries = ConvertStringToMatchupEntryModel(cols[1]);
                if (cols[2].Length == 0)
                {
                    matchup.Winner = null;
                }
                else
                {
                    matchup.Winner = LookupTeamById(int.Parse(cols[2]));
                }

                matchup.MatchupRound = int.Parse(cols[3]);

                output.Add(matchup);
            }

            return(output);
        }
示例#4
0
        public static List <MatchupModel> ConvertToMatchupModels(this List <string> lines)
        {
            //pipe delimited
            List <MatchupModel> output = new List <MatchupModel>();

            foreach (string line in lines)
            {
                string[] cols = line.Split(',');

                MatchupModel p = new MatchupModel();
                p.Id      = int.Parse(cols[0]); //i want the app to crash if fails integrity of data
                p.Entries = ConvertStringToMatchupEntryModel(cols[1]);
                if (cols[2].Length == 0)
                {
                    p.Winner = null;
                }
                else
                {
                    p.Winner = LookupTeamById(int.Parse(cols[2]));
                }

                p.MatchupRound = int.Parse(cols[3]);
                output.Add(p);
            }
            return(output);
        }
示例#5
0
        public List <MatchupModel> ReadMatchups(string date)
        {
            var output = new List <MatchupModel>();
            var turn   = new TurnAggregationModel();

            foreach (var elem in _context.Turns.ToList())
            {
                if (elem.Date.ToShortDateString() == date)
                {
                    turn = elem;
                }
            }

            var dict  = JsonConvert.DeserializeObject <Dictionary <string, string> >(turn.Matches);
            var split = dict["matchups"].Split(';');

            foreach (var elem in split)
            {
                var matchup = elem.Split(',');
                if (elem != "")
                {
                    MatchupModel tmp = new MatchupModel
                    {
                        Player1 = matchup[0], Player2 = matchup[1], Winner = matchup[2]
                    };
                    output.Add(tmp);
                }
            }

            return(output);
        }
        public static List <MatchupModel> ConvertToMatchupModels(this List <string> lines)
        {
            //id=0, entries=1(pipe delimeted by id), winner = 2, matchupRound = 3
            List <MatchupModel> output = new List <MatchupModel>();

            foreach (string line in lines)
            {
                string[]     cols = line.Split(','); //разделяем запятыми и кладем в массив под названием cols
                MatchupModel p    = new MatchupModel();
                p.Id      = int.Parse(cols[0]);      //проверка на номер, на число
                p.Entries = ConvertStringToMatchupEntryModels(cols[1]);

                if (cols[2].Length == 0)
                {
                    p.Winner = null;
                }
                else
                {
                    p.Winner = LookupTeamById(int.Parse(cols[2]));
                }

                p.MatchupRound = int.Parse(cols[3]);

                output.Add(p);
            }

            return(output);
        }
示例#7
0
        private static void CreateOtherRounds(TournamentModel model, int rounds)
        {
            int round = 2;
            List <MatchupModel> previousRound = model.Rounds[0];
            List <MatchupModel> currRound     = new List <MatchupModel>();
            MatchupModel        currMatchup   = new MatchupModel();

            while (round <= rounds)
            {
                foreach (MatchupModel match in previousRound)
                {
                    currMatchup.Entries.Add(new MatchupEntryModel {
                        ParentMatchup = match
                    });
                    if (currMatchup.Entries.Count > 1)
                    {
                        currMatchup.MatchupRound = round;
                        currRound.Add(currMatchup);
                        currMatchup = new MatchupModel();
                    }
                }
                model.Rounds.Add(currRound);
                previousRound = currRound;
                currRound     = new List <MatchupModel>();
                round++;
            }
        }
        private void LoadMatchup(MatchupModel m)
        {
            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        teamOneName.Text       = m.Entries[0].TeamCompeting.TeamName;
                        teamOneScoreValue.Text = m.Entries[0].Score.ToString();
                        teamTwoName.Text       = "<bye>";
                        teamTwoScoreValue.Text = "0";
                    }
                    else
                    {
                        teamOneName.Text       = "Not yet set";
                        teamOneScoreValue.Text = "";
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        teamTwoName.Text       = m.Entries[1].TeamCompeting.TeamName;
                        teamTwoScoreValue.Text = m.Entries[1].Score.ToString();
                    }
                    else
                    {
                        teamTwoName.Text       = "Not yet set";
                        teamTwoScoreValue.Text = "";
                    }
                }
            }
        }
        private string IsValidScoreData(MatchupModel matchup)
        {
            string output = string.Empty;

            bool scoreTeamOneValid = double.TryParse(teamOneScoreValue.Text, out double scoreTeamOne);
            bool scoreTeamTwoValid = double.TryParse(teamTwoScoreValue.Text, out double scoreTeamTwo);

            if (!scoreTeamOneValid)
            {
                output = $"Please enter a valid score for { matchup.Entries[0].TeamCompeting.TeamName }";
            }
            else if (!scoreTeamTwoValid)
            {
                output = $"Please enter a valid score for { matchup.Entries[1].TeamCompeting.TeamName }";
            }
            else if (scoreTeamOne == 0 && scoreTeamTwo == 0)
            {
                output = "You did not enter a score for either team";
            }
            else if (scoreTeamOne == scoreTeamTwo)
            {
                output = "Tie scores are not allowed";
            }

            return(output);
        }
示例#10
0
        private static List <MatchupModel> CreateFirstRound(List <EntryModel> entries, int byeAmount)
        {
            List <MatchupModel> output         = new List <MatchupModel>();
            MatchupModel        currentMatchup = new MatchupModel();

            foreach (EntryModel entry in entries)
            {
                currentMatchup.MatchupEntries.Add(new MatchupEntryModel {
                    EntryCompeting = entry
                });

                if (byeAmount > 0 || currentMatchup.MatchupEntries.Count > 1)
                {
                    currentMatchup.MatchupRound = 1;
                    output.Add(currentMatchup);
                    currentMatchup = new MatchupModel();

                    if (byeAmount > 0)
                    {
                        byeAmount--;
                    }
                }
            }

            return(output);
        }
示例#11
0
        private static void CreateOtherRounds(TournamentModel tournament, int roundAmount)
        {
            if (roundAmount == 1)
            {
                return;
            }

            int round = 2;
            List <MatchupModel> previousRound  = tournament.Rounds[0];
            List <MatchupModel> currentRound   = new List <MatchupModel>();
            MatchupModel        currentMatchup = new MatchupModel();

            while (round <= roundAmount)
            {
                foreach (MatchupModel matchup in previousRound)
                {
                    currentMatchup.MatchupEntries.Add(new MatchupEntryModel {
                        ParentMatchup = matchup
                    });

                    if (currentMatchup.MatchupEntries.Count > 1)
                    {
                        currentMatchup.MatchupRound = round;
                        currentRound.Add(currentMatchup);
                        currentMatchup = new MatchupModel();
                    }
                }

                tournament.Rounds.Add(currentRound);
                previousRound = currentRound;

                currentRound = new List <MatchupModel>();
                round++;
            }
        }
示例#12
0
        private static void CreateRemainingRounds(TournamentModel tournament, int requiredRounds)
        {
            int generatingRound = 2;
            List <MatchupModel> previousRoundMatches = tournament.Rounds[0];
            List <MatchupModel> currentRoundMatches  = new List <MatchupModel>();
            MatchupModel        currentMatchup       = new MatchupModel();

            while (generatingRound <= requiredRounds)
            {
                foreach (MatchupModel match in previousRoundMatches)
                {
                    currentMatchup.Entries.Add(new MatchupEntryModel {
                        ParentMatchup = match
                    });

                    if (currentMatchup.Entries.Count > 1)
                    {
                        currentMatchup.MatchupRound = generatingRound;
                        currentRoundMatches.Add(currentMatchup);
                        currentMatchup = new MatchupModel();
                    }
                }

                tournament.Rounds.Add(currentRoundMatches);
                previousRoundMatches = currentRoundMatches;
                currentRoundMatches  = new List <MatchupModel>();
                generatingRound     += 1;
            }
        }
        public static List <MatchupModel> ConvertToMatchupModel(this List <string> lines)
        {
            //id=0,entries=1(pipe delimted by id), winner = 2, matchupRound =3
            List <MatchupModel> output = new List <MatchupModel>();

            foreach (string line in lines)
            {
                string[] cols = line.Split(',');

                MatchupModel p = new MatchupModel();
                p.Id      = int.Parse(cols[0]);
                p.Entries = ConvertStringToMatchupEntryModels(cols[1]);
                if (cols[2].Length == 0)
                {
                    p.Winner = null;
                }
                else
                {
                    p.Winner = LookUpTeamById(int.Parse(cols[2]));
                }

                p.MatchRound = int.Parse(cols[3]);
                output.Add(p);
            }
            return(output);
        }
示例#14
0
        public static List <MatchupModel> ConvertToMatchupModels(this List <string> lines)
        {
            List <MatchupModel> output = new List <MatchupModel>();

            foreach (string line in lines)
            {
                if (line != "")
                {
                    string[] cols = line.Split(',');

                    MatchupModel m = new MatchupModel();
                    m.Id      = int.Parse(cols[0]);
                    m.Entries = ConvertStringToMatchupEntryModels(cols[1]);

                    if (cols[2].Length == 0)
                    {
                        m.Winner = null;
                    }
                    else
                    {
                        m.Winner = LookupTeamById(int.Parse(cols[2]));
                    }

                    m.MatchupRound = int.Parse(cols[3]);

                    output.Add(m);
                }
            }
            return(output);
        }
示例#15
0
        public void UpdateMatchup(MatchupModel model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                if (model.Winner != null)
                {
                    p.Add("@id", model.Id);
                    p.Add("@WinnerId", model.Winner.Id);

                    connection.Execute("dbo.spMatchups_Update", p, commandType: CommandType.StoredProcedure);
                }

                //dbo.spMatchupEntries_Update id, TeamCompetingId, Score
                foreach (MatchupEntryModel me in model.Entries)
                {
                    if (me.TeamCompeting != null)
                    {
                        p = new DynamicParameters();
                        p.Add("@id", me.Id);
                        p.Add("@TeamCompetingId", me.TeamCompeting.Id);
                        p.Add("@Score", me.Score);

                        connection.Execute("dbo.spMatchupEntries_Update", p, commandType: CommandType.StoredProcedure);
                    }
                }
            }
        }
示例#16
0
        public static void UpdateMatchupToFile(this MatchupModel matchup)
        {
            List <MatchupModel> matchups   = GlobalConfig.MatchupsFile.FullFilePath().LoadFile().ConvertToMatchupModel();
            MatchupModel        oldMatchup = new MatchupModel();

            foreach (MatchupModel m in matchups)
            {
                if (m.Id == matchup.Id)
                {
                    oldMatchup = m;
                }
            }

            matchups.Remove(oldMatchup);
            matchups.Add(matchup);

            foreach (MatchupEntryModel entry in matchup.Entries)
            {
                entry.UpdateEntryToFile();
            }

            List <string> lines = new List <string>();

            foreach (MatchupModel m in matchups)
            {
                string winner = "";
                if (m.Winner != null)
                {
                    winner = m.Winner.Id.ToString();
                }
                lines.Add($"{ m.Id },{ ConvertEntryListToString(m.Entries) },{ winner },{ m.MatchupRound }");
            }

            File.WriteAllLines(GlobalConfig.MatchupsFile.FullFilePath(), lines);
        }
示例#17
0
        public static List <MatchupModel> ConvertToMatchupModel(this List <string> lines)
        {
            List <MatchupModel> output = new List <MatchupModel>();

            foreach (string line in lines)
            {
                string[]     cols = line.Split(',');
                MatchupModel p    = new MatchupModel
                {
                    Id           = int.Parse(cols[0]),
                    Entries      = ConvertStringToMatchupEntryModel(cols[1]),
                    MatchupRound = int.Parse(cols[3])
                };
                if (cols[2].Length == 0)
                {
                    p.Winner = null;
                }
                else
                {
                    p.Winner = LookupTeamById(int.Parse(cols[2]));
                }
                output.Add(p);
            }

            return(output);
        }
示例#18
0
        public static void SaveMatchupToFile(this MatchupModel matchup)
        {
            List <MatchupModel> matchups = GlobalConfig.MatchupsFile.FullFilePath().LoadFile().ConvertToMatchupModel();

            int currId = 1;

            if (matchups.Count > 0)
            {
                currId = matchups.OrderByDescending(x => x.Id).First().Id + 1;
            }
            matchup.Id = currId;
            matchups.Add(matchup);

            foreach (MatchupEntryModel entry in matchup.Entries)
            {
                entry.SaveEntryToFile();
            }

            List <string> lines = new List <string>();

            foreach (MatchupModel m in matchups)
            {
                string winner = "";
                if (m.Winner != null)
                {
                    winner = m.Winner.Id.ToString();
                }
                lines.Add($"{ m.Id },{ ConvertEntryListToString(m.Entries) },{ winner },{ m.MatchupRound }");
            }

            File.WriteAllLines(GlobalConfig.MatchupsFile.FullFilePath(), lines);
        }
示例#19
0
        private static void DetermineWinner(MatchupModel matchup)
        {
            string greaterWins = ConfigurationManager.AppSettings["greaterScoreWins"];

            if (matchup.MatchupEntries.Count == 1)
            {
                matchup.Winner = matchup.MatchupEntries[0].EntryCompeting;
            }
            else if (matchup.MatchupEntries.Count == 2)
            {
                if (greaterWins == "1")
                {
                    matchup.Winner = matchup.MatchupEntries[0].Score > matchup.MatchupEntries[1].Score ? matchup.MatchupEntries[0].EntryCompeting : matchup.MatchupEntries[1].EntryCompeting;
                }
                else if (greaterWins == "0")
                {
                    matchup.Winner = matchup.MatchupEntries[0].Score < matchup.MatchupEntries[1].Score ? matchup.MatchupEntries[0].EntryCompeting : matchup.MatchupEntries[1].EntryCompeting;
                }
                else
                {
                    throw new Exception("Invalid value of option \"greaterWins\".");
                }
            }
            else
            {
                throw new Exception();
            }
        }
示例#20
0
        public static List <MatchupModel> ConvertToMatchupModels(this List <string> lines)
        {
            // text file columns to array
            // id=0, entries=1(pipe delimited by id), winner=2, matchupround=3
            List <MatchupModel> output = new List <MatchupModel>();

            foreach (string line in lines)
            {
                string[] cols = line.Split(',');

                MatchupModel m = new MatchupModel();
                m.Id           = int.Parse(cols[0]);
                m.Entries      = ConvertStringToMatchupEntryModels(cols[1]);
                m.MatchupRound = int.Parse(cols[3]);
                if (cols[2].Length == 0)
                {
                    m.Winner = null;
                }
                else
                {
                    m.Winner = LookUpTeamById(int.Parse(cols[2]));
                }
                //m.Winner = LookUpTeamById(int.Parse(cols[2]));
                output.Add(m);
            }

            return(output);
        }
示例#21
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage != string.Empty)
            {
                MessageBox.Show($"Input Error: {errorMessage}");
                return;
            }

            MatchupModel m            = (MatchupModel)matchupListbox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[i].TeamCompeting != null)
                    {
                        if (double.TryParse(teamOneScoreValue.Text, out teamOneScore))
                        {
                            m.Entries[i].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show($"Please enter a valid score for team {i}");
                            return;
                        }
                    }
                }
                else
                {
                    if (m.Entries[i].TeamCompeting != null)
                    {
                        if (double.TryParse(teamTwoScoreValue.Text, out teamTwoScore))
                        {
                            m.Entries[i].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show($"Please enter a valid score for team {i}");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }

            LoadMatchups((int)roundDropdown.SelectedItem);
        }
示例#22
0
        private static string SerializeMatchup(MatchupModel matchup)
        {
            // [id],(MatchupEntries)[id|id|id],(Winner)[id],[MatchupRound]

            string output = $"{ matchup.id },{ SerializeList(matchup.MatchupEntries, '|') },{ matchup.Winner?.id.ToString() },{ matchup.MatchupRound }";

            return(output);
        }
示例#23
0
        private const string DB = "Tournaments"; // MAGIC STRING

        //////////////////////////CREATION MODELS FOR INSERTING INTO SQL TOP///////////////////////
        public MatchupModel CreateMatchup(MatchupModel matchupModel)
        {
            throw new NotImplementedException();
            ///using statement for complete garabage collection after method is run
            using (IDbConnection connection = new SqlConnection(GlobalConfig.CnnString(DB)))
            {
            }
        }
示例#24
0
        private void TVScoreButton_Click(object sender, EventArgs e)
        {
            MatchupModel m            = (MatchupModel)TVScoringRoundListBox.SelectedItem;
            string       errorMessage = ValidateScore();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Input error: {errorMessage}");
                TVScoringTeamOneTextBox.Text = "0";
                TVScoringTeamTwoTextBox.Text = "0";
                return;
            }

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreParsed = double.TryParse(TVScoringTeamOneTextBox.Text, out double teamOneScore);
                        if (scoreParsed)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for the first team.");
                            return;
                        }
                    }
                }
                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreParsed = double.TryParse(TVScoringTeamTwoTextBox.Text, out double teamTwoScore);
                        if (scoreParsed)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for the second team.");
                            return;
                        }
                    }
                }
            }
            try
            {
                UpdateResults.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application encountered the following error: {ex.Message }");
                return;
            }
        }
        private void MatchupListbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            MatchupModel matchup = (MatchupModel)matchupListbox.SelectedItem;

            if (matchup != null)
            {
                LoadMatchup(matchup);
            }
        }
        public IActionResult PrepareMatchup(string EventId, string Player1, string Player2)
        {
            var matchup = new MatchupModel();

            matchup.Player1 = Player1;
            matchup.Player2 = Player2;
            matchup.Winner  = Player1;
            matchup.EventId = Convert.ToInt32(EventId);
            return(SubmitScore(matchup));
        }
        private void scoreButton_Click(object sender, EventArgs e)
        {
            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);
                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 1.");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2.");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
            }

            LoadMatchups();
            WireUpMatchupsLists();
        }
示例#28
0
        public async Task <IActionResult> Create([Bind("Id,IsFinished,Date")] MatchupModel matchupModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(matchupModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(matchupModel));
        }
        public void UpdateMatchup(MatchupModel model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.ConnectionString("TournamentTracker")))
            {
                var dbData = new DynamicParameters();
                dbData.Add("@id", model.Id);
                dbData.Add("@WinnerId", model.WinnerId);

                connection.Execute("dbo.spMatchup_UpdateById", dbData, commandType: CommandType.StoredProcedure);
            }
        }
示例#30
0
        public static void SaveMatchupToFile(this MatchupModel matchup, string matchupFile, string matchupEntryFile)
        {
            List <MatchupModel> matchups = GlobalConfig.MatchupFile
                                           .FullFilePath()
                                           .LoadFile()
                                           .ConvertToMatchupModels();

            int currentId = 1;

            if (matchups.Count > 0)
            {
                currentId = matchups.OrderByDescending(x => x.Id).First().Id + 1; //lo ordena por orden inverso de IDs y le añade 1
            }
            matchup.Id = currentId;

            matchups.Add(matchup);

            //save to file

            List <string> lines = new List <string>();

            //id=0, entries =1 (pipe delimted by id), winner=2, matchupRound=3
            foreach (MatchupModel m in matchups)
            {
                string winner = "";
                if (m.Winner != null)
                {
                    winner = m.Winner.Id.ToString();
                }
                lines.Add($"{m.Id},{""},{winner},{m.MatchupRound} ");
            }
            File.WriteAllLines(GlobalConfig.MatchupFile.FullFilePath(), lines);

            foreach (MatchupEntryModel entry in matchup.Entries)
            {
                entry.SaveEntryToFile(matchupEntryFile);
            }
            //save to file

            lines = new List <string>();

            //id=0, entries =1 (pipe delimted by id), winner=2, matchupRound=3
            foreach (MatchupModel m in matchups)
            {
                string winner = "";
                if (m.Winner != null)
                {
                    winner = m.Winner.Id.ToString();
                }
                lines.Add($"{m.Id},{ConvertMatchupEntryListToString(m.Entries)},{winner},{m.MatchupRound} ");
            }
            File.WriteAllLines(GlobalConfig.MatchupFile.FullFilePath(), lines);
        }