示例#1
0
        public NPGame Save(NPGame game)
        {
            using (var context = GetContext())
            {
                if (game.Id == 0)
                {
                    context.NPGames.Add(game);
                }
                else
                {
                    context.Entry<NPGame>(game).State = System.Data.EntityState.Modified;
                }

                context.SaveChanges();
                if (game.HigherSeedScore.HasValue && game.LowerSeedScore.HasValue)
                {
                    context.Database.ExecuteSqlCommand("dbo.usp_NPGame_Save @GameID, @Team1Score, @Team2Score",
                        new SqlParameter("GameID", game.Id),
                        new SqlParameter("Team1Score", game.HigherSeedScore ?? 0),
                        new SqlParameter("Team2Score", game.LowerSeedScore ?? 0));
                }
                return game;
            }
        }
示例#2
0
 public ActionResult SaveGame(NPGame game)
 {
     _gameService.Save(game);
     return RedirectToAction("Game");
 }
示例#3
0
 public NPGame Save(NPGame game)
 {
     return _repository.Save(game);
 }