コード例 #1
0
        public IGameViewModel Play(IGameViewModel gameModel, Random random)
        {
            using (var db = new JUGContext())
            {
                var gameDAO = GameDataService.GetById(gameModel.Id, db);

                var game = Mapper.DAOToDomain(gameDAO);

                game.Play(new Random());

                MapGameResults(gameDAO, game);

                GameDataService.Save(gameDAO, db);
                GameDataService.SaveChanges(db);

                var resultModel = Mapper.DomainToViewModel(game);

                return(resultModel);
            }
        }
コード例 #2
0
        public IGameViewModel Update(IGameViewModel gameModel)
        {
            using (var db = new JUGContext())
            {
                var gameDAO = GameDataService.GetById(gameModel.Id, db);

                if (gameDAO.Home.Id != gameModel.HomeId)
                {
                    var newHomeTeam = TeamDataService.GetById(gameModel.HomeId, db);
                    //check if null
                    gameDAO.Home = newHomeTeam;
                }

                if (gameDAO.Away.Id != gameModel.AwayId)
                {
                    var newAwayTeam = TeamDataService.GetById(gameModel.AwayId, db);
                    //check if null
                    gameDAO.Away = newAwayTeam;
                }
            }

            return(null);
        }