Пример #1
0
        public ActionResult Create(FormCollection collection)
        {
            var game = new Game();
            try
            {
                var now = DateTime.Now;
                game.EventStartDate = CombineDateAndTime(collection.Get("EventStartDate"), collection.Get("EventStartTime"));
                game.EventEndDate = CombineDateAndTime(collection.Get("EventEndDate"), collection.Get("EventEndTime"));
                var loc = collection.Get("EventLocation");
                if (!String.IsNullOrEmpty(loc))
                {
                    game.EventLocation = collection.Get("EventLocation");
                }
                game.IsActive = true;
                game.VisitingTeamId = Convert.ToInt64(collection.Get("VisitingTeamId"));
                game.TeamId = Convert.ToInt64(collection.Get("TeamId"));
                game.TimeZone = collection.Get("TimeZone");
                game.SeasonId = Convert.ToInt64(collection.Get("SeasonId"));
                game.DateCreated = now;
                game.DateUpdated = now;

                this.repo.Save(game);

                return RedirectToAction("Index");
            }
            catch
            {
                ViewBag.Seasons = this.GetActiveSeasons();
                ViewBag.TeamTypes = this.GetTeamTypes();
                return View(game);
            }
        }
Пример #2
0
        private void FixupGame(Game previousValue)
        {
            if (previousValue != null && previousValue.GamePrices.Contains(this))
            {
                previousValue.GamePrices.Remove(this);
            }

            if (Game != null)
            {
                if (!Game.GamePrices.Contains(this))
                {
                    Game.GamePrices.Add(this);
                }
                if (GameId != Game.GameId)
                {
                    GameId = Game.GameId;
                }
            }
        }