예제 #1
0
        public void Create(GameBLModel game)
        {
            if (string.IsNullOrWhiteSpace(game.Name) ||
                string.IsNullOrWhiteSpace(game.Key)
                )
            {
                return;
            }

            GameDataModel gameToCreate = Mapper.Map <GameDataModel>(game);

            _unitOfWork.GameRepository.Create(gameToCreate);
        }
예제 #2
0
        public void Update(GameBLModel game)
        {
            if (string.IsNullOrWhiteSpace(game.Name) ||
                string.IsNullOrWhiteSpace(game.Key)
                )
            {
                return;
            }

            GameDataModel gameToUpdate = _unitOfWork.GameRepository.GetById(game.Id);

            if (gameToUpdate == null)
            {
                Create(game);
                return;
            }
            gameToUpdate.Name        = game.Name;
            gameToUpdate.Description = game.Description;
            gameToUpdate.Key         = game.Key;
            //ToDo if genres or platforms changed
            _unitOfWork.GameRepository.Update(gameToUpdate);
            _unitOfWork.Save();
        }