public GameViewModel AddGame(int hId, int aId, DateTime gDt, bool isPlayoff, bool isSuperbowl, int week) { var game = new Game() { HomeTeam_Id = hId, AwayTeam_Id = aId, GameDateTime = gDt, IsPlayoff = isPlayoff, IsSuperbowl = isSuperbowl, Week = week, Season = _ctx.Seasons.GetCurrentSeason().SingleOrDefault(), HomeTeamScore = 0, AwayTeamScore = 0 }; // _ctx.AddToGames(game); _ctx.SaveChanges(); // setup auto-mapper AutoMapperConfiguration.Setup(_ctx); // calculate the playoff and superbowl picks only if you are adding a playoff or superbowl game if (isSuperbowl || isPlayoff) { // calculate the superbowl and playoff picks CalcSuperbowlPlayoffPicks(null); } // return the game we just added return Mapper.Map<Game, GameViewModel>(game); }
/// <summary> /// Create a new Game object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="season_Id">Initial value of the Season_Id property.</param> /// <param name="gameDateTime">Initial value of the GameDateTime property.</param> /// <param name="isPlayoff">Initial value of the IsPlayoff property.</param> /// <param name="isSuperbowl">Initial value of the IsSuperbowl property.</param> /// <param name="week">Initial value of the Week property.</param> /// <param name="homeTeam_Id">Initial value of the HomeTeam_Id property.</param> /// <param name="awayTeam_Id">Initial value of the AwayTeam_Id property.</param> public static Game CreateGame(global::System.Int32 id, global::System.Int32 season_Id, global::System.DateTime gameDateTime, global::System.Boolean isPlayoff, global::System.Boolean isSuperbowl, global::System.Int32 week, global::System.Int32 homeTeam_Id, global::System.Int32 awayTeam_Id) { Game game = new Game(); game.Id = id; game.Season_Id = season_Id; game.GameDateTime = gameDateTime; game.IsPlayoff = isPlayoff; game.IsSuperbowl = isSuperbowl; game.Week = week; game.HomeTeam_Id = homeTeam_Id; game.AwayTeam_Id = awayTeam_Id; return game; }
/// <summary> /// Deprecated Method for adding a new object to the Games EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToGames(Game game) { base.AddObject("Games", game); }