Ejemplo n.º 1
0
        public async Task <string> Initialize(InitializeDTO initializeDTO)
        {
            if (!ModelState.IsValid)
            {
                return(null);
            }
            User user = await this._userManager.GetUserAsync(HttpContext.User);

            string numberWhichUserMustGuess = _gameHandler.GenerateUniqueDigitsNumber();

            user.Games.Add(new Game()
            {
                NumberWhichUserMustGuess = numberWhichUserMustGuess.ToString(),
                NumberWhichAIMustGuess   = initializeDTO.numberToGuess
            });
            await _context.SaveChangesAsync();

            return(initializeDTO.numberToGuess);
        }