示例#1
0
        public async Task <IActionResult> Create(Player newPlayer, IFormCollection collection)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(newPlayer));
                }

                await _playerRepository.AddNewPlayerAsync(newPlayer);

                var returnedPlayer = await _playerRepository.GetByPlayerByName(newPlayer.PlayerName);

                await AddPlayerRankingMethod.AddPlayerRanking(returnedPlayer, _rankingRepository, _playerRepository);

                return(RedirectToAction(nameof(Index)));
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(View(newPlayer));
        }