// Update race public void UpdateRace(int ID) { Race race = new Race(); if (TryUpdateModel(race, new FormValueProvider(ModelBindingExecutionContext))) { RaceManagment.UpdateRace(race); } }
// Modify race public static void UpdateRace(Race race) { List<Race> races = GetAllRaces(); races.RemoveAll(x => x.ID == race.ID); races.Add(race); File.Delete(_fileWithRaces); foreach (Race x in races) { AddRace(x); } }
// Add race public static void AddRace(Race race) { string token = ""; string[] strings = { race.ID.ToString(), race.Airport, race.Departure, race.Destination, race.DepartureDateTime.ToString(), race.DestinationDateTime.ToString(), race.DelayTimeSpan.ToString() }; foreach (string x in strings) { token += x; token += _crazyToken; } File.AppendAllLines(_fileWithRaces, new string[] { token }); }
// New race public void InsertRace() { Race race = new Race(); if (TryUpdateModel(race, new FormValueProvider(ModelBindingExecutionContext))) { int id = int.Parse(File.ReadAllText(_fileWithID)); race.ID = id; id++; File.WriteAllText(_fileWithID, id.ToString()); RaceManagment.AddRace(race); } }