public async Task <IActionResult> Create(Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(player));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,WinnerId")] Tournament tournament)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tournament);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WinnerId"] = new SelectList(_context.Player, "Id", "Id", tournament.WinnerId);
            return(View(tournament));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Date,Player1Id,Player2Id,TournamentId")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Player1Id"]    = new SelectList(_context.Player, "Id", "Id", game.Player1Id);
            ViewData["Player2Id"]    = new SelectList(_context.Player, "Id", "Id", game.Player2Id);
            ViewData["TournamentId"] = new SelectList(_context.Set <Tournament>(), "Id", "Id", game.TournamentId);
            return(View(game));
        }