public ActionResult Create(FormCollection collection) { var season = new Season(); try { var now = DateTime.Now; season.EventStartDate = Convert.ToDateTime(collection.Get("EventStartDate")); season.EventEndDate = Convert.ToDateTime(collection.Get("EventEndDate")); season.EventLocation = collection.Get("EventLocation"); season.IsActive = true; season.IsArchived = false; season.Opponent = collection.Get("Opponent"); season.SeasonTypeId = Convert.ToInt32(collection.Get("SeasonTypeId")); season.TeamId = Convert.ToInt64(collection.Get("TeamId")); season.TimeZone = collection.Get("TimeZone"); season.SeasonYearsId = this.GetSeasonYearsId(collection.Get("SeasonYearsId")); season.DateCreated = now; season.DateUpdated = now; this.seasonRepo.Save(season); return RedirectToAction("Index"); } catch { ViewBag.TeamTypes = this.GetTeamTypes(); ViewBag.SeasonTypes = this.GetTeamTypes(); return View(season); } }
private void FixupSeason(Season previousValue) { if (previousValue != null && previousValue.Games.Contains(this)) { previousValue.Games.Remove(this); } if (Season != null) { if (!Season.Games.Contains(this)) { Season.Games.Add(this); } if (SeasonId != Season.SeasonId) { SeasonId = Season.SeasonId; } } }