Esempio n. 1
0
        private static List <MatchUpEntry> ConvertToMatchupEntries(this List <string> lines)
        {
            var outputMatchupEntries = new List <MatchUpEntry>();

            foreach (var line in lines)
            {
                string[] cols         = line.Split('|');
                var      matchupEntry = new MatchUpEntry
                {
                    Id            = int.Parse(cols[0]),
                    TeamCompeting = LookupTeamById(int.Parse(cols[1])),
                    Score         = double.Parse(cols[2])
                };

                if (int.TryParse(cols[3], out int parentID))
                {
                    matchupEntry.Parent = LookupMacthupEntryById(int.Parse(cols[3]));
                }
                else
                {
                    matchupEntry.Parent = null;
                }

                outputMatchupEntries.Add(matchupEntry);
            }

            return(outputMatchupEntries);
        }
Esempio n. 2
0
        private static void SaveMatchupEntryToFile(this MatchUpEntry matchUpEntry, string mactupEntryFile)
        {
            var matchupEntries = GlobalConfig.MatchupEntryFile.FullFilePath().LoadFile().ConvertToMatchupEntries();
            int currentId      = 1;

            if (matchupEntries.Count > 0)
            {
                currentId = matchupEntries.OrderByDescending(x => x.Id).First().Id + 1;
            }

            matchUpEntry.Id = currentId;
            matchupEntries.Add(matchUpEntry);

            var lines = new List <string>();

            foreach (var _matchupEntry in matchupEntries)
            {
                lines.Add($"{ _matchupEntry.Id },{ _matchupEntry.TeamCompeting.Id },{ _matchupEntry.Score },{ _matchupEntry.Parent.Id }");
            }

            File.WriteAllLines(GlobalConfig.MatchupEntryFile.FullFilePath(), lines);
        }