public TournamentTabViewModel() { Tournament = new Tournament(); _allTournamentNames = new TrulyObservableCollection<TournamentName>(); TournamentDescriptionNames = new TrulyObservableCollection<TournamentDescription>(); TournamentDescription = new TournamentDescription(); TournamentDescriptionNameIndex = -1; TournamentChairmen = new TrulyObservableCollection<TournamentChairman>(); TournamentChairmenSelectedIndex = -1; ReadTournamentChairmen(); }
public TournamentDescriptionTabViewModel() { TournamentDescriptionNames = new TrulyObservableCollection<WebAdmin.TournamentDescription>(); TournamentDescription = new TournamentDescription(); TournamentDescriptionNameIndex = -1; }
protected void LoadTournamentDescriptionsFromWebResponse(string responseString, TrulyObservableCollection<TournamentDescription> tournamentDescriptionNames) { string[] lines = responseString.Split('\n'); string[][] csvParsedLines = CSVParser.Parse(lines); bool clearedDescriptions = false; int lineNumber = 0; foreach (var fields in csvParsedLines) { lineNumber++; if ((fields.Length == 0) || string.IsNullOrWhiteSpace(fields[0])) continue; if (!clearedDescriptions) { clearedDescriptions = true; } if (fields.Length < 3) { // the description contains newlines, so the line number doesn't match up ... throw new ArgumentException(string.Format("Website response: line {0}: contains fewer than 3 fields: {1}", lineNumber, lines[lineNumber - 1])); } var td = new TournamentDescription(); int key; if (!int.TryParse(fields[0], out key)) { throw new ArgumentException(string.Format("Website response: line {0}: contains a bad key: {1}", lineNumber, fields[0])); } td.TournamentDescriptionKey = key; td.Name = fields[1]; td.Description = fields[2].Replace("\r\r", "\r"); tournamentDescriptionNames.Add(td); } }