public async Task <IActionResult> Create([Bind("TeamId,LeagueId,Name,Initials,FoundingDate,NumberOfTitles,MainColor")] Team team)
        {
            if (ModelState.IsValid)
            {
                _context.Add(team);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LeagueId"] = new SelectList(_context.League, "LeagueId", "LeagueId", team.LeagueId);
            return(View(team));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Playerid,TeamId,Name,DateOfBirth,MarketValue")] Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Team, "TeamId", "Initials", player.TeamId);
            return(View(player));
        }