public async Task <IActionResult> AddNewGame([FromBody] GameCreateDTO game)
        {
            Game newGame = new Game {
                name       = game.userName,
                start_date = DateTime.Now
            };

            var value = _context.Game.Add(newGame);
            await _context.SaveChangesAsync();

            return(Ok(newGame.game_id));
        }
Beispiel #2
0
        public void CreateNewGame(GameCreateDTO game)
        {
            Game gameToCreate = new Game();

            Mapper.Map(game, gameToCreate);
            SetGenres(game, gameToCreate);
            SetPlatforms(game, gameToCreate);
            if (_unitOfWork.GameRepository.Get(i => i.Key.Equals(game.Key)).ToList().Count == 0)
            {
                _unitOfWork.GameRepository.Create(gameToCreate);
                _unitOfWork.Commit();
            }
        }
Beispiel #3
0
        public async Task <GameDTO> CreateGameAsync(GameCreateDTO game)
        {
            var gameEntity = mapper.Map <Game>(game);

            using var uow = UnitOfWorkProvider.Create();

            var gameId = await gameRepository.CreateAsync(gameEntity);

            var createdGame = await gameRepository.GetByIdAsync(gameId);

            await uow.CommitAsync();

            return(mapper.Map <GameDTO>(createdGame));
        }
Beispiel #4
0
        public async Task <IActionResult> AddNewGame([FromBody] GameCreateDTO game)
        {
            Console.WriteLine(game);
            Game newGame = new Game {
                name       = game.user_name,
                start_date = DateTime.Now,
                lang_code  = game.language_code
            };

            var value = _context.Game.Add(newGame);
            await _context.SaveChangesAsync();

            return(Ok(newGame.game_id));
        }