internal bool UpdateSeason(Season season) { if (!RemoveSeason(season)) { return false; } Seasons.Add(season); using (StreamWriter seasonFile = new StreamWriter(_seasonPath,false)) { seasonFile.WriteLine("#Seasons"); seasonFile.WriteLine("#ID\tNumber\tStart\tEnd\tDescription"); foreach (Season thisSeason in Seasons.OrderBy(s=> s.ID)) { seasonFile.WriteLine(thisSeason.ToString()); } seasonFile.Flush(); } return true; }
private void LoadSeasons() { if (!File.Exists(_seasonPath)) { throw new ArgumentException("Missing Season and/or Rank file(s)."); } if (AllRanks.Count == 0) { LoadRanks(); } using (StreamReader seasonFile = new StreamReader(_seasonPath)) { string seasonLine; while ((seasonLine = seasonFile.ReadLine()) != null) { if (seasonLine.StartsWith("#")) { continue; } string[] seasonData = seasonLine.Split('\t'); if (seasonData.Length >= 5 ) { Season thisSeason = new Season(); thisSeason.ID = int.Parse(seasonData[0]); thisSeason.Number = int.Parse(seasonData[1]); thisSeason.Start = DateTime.Parse(seasonData[2]); thisSeason.End = DateTime.Parse(seasonData[3]); thisSeason.Description = seasonData[4]; thisSeason.Ranks = AllRanks.Where(r => r.ExpirationDate > thisSeason.Start).ToList(); Seasons.Add(thisSeason); } } } }
internal bool RemoveSeason(Season season) { if (Seasons.Any(s => s.ID == season.ID)) { Seasons.Remove(Seasons.First(s => s.ID == season.ID)); return RemoveSeason(season); } return true; }
internal bool AddSeason(Season season) { return UpdateSeason(season); }
public bool UpdateSeason(Season season) { return _fileData.UpdateSeason(season); }
public bool DeleteSeason(Season season) { return _fileData.RemoveSeason(season); }
public bool AddSeason(Season season) { return _fileData.AddSeason(season); }