public async Task <IActionResult> Create([Bind("LeagueId,Year")] League league)
        {
            // Validates and creates the object based on the given fields
            if (ModelState.IsValid)
            {
                _context.Add(league);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(league));
        }
        public async Task <IActionResult> Create([Bind("StatsId,Goals,Assists,Saves,MatchId,PlayerId")] Stats stats)
        {
            // Validates and creates the object based on the given fields
            if (ModelState.IsValid)
            {
                _context.Add(stats);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stats));
        }
        public async Task <IActionResult> Create([Bind("TeamId,Name,Location")] Team team)
        {
            // Validates and creates the object based on the given fields
            if (ModelState.IsValid)
            {
                _context.Add(team);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(team));
        }
        public async Task <IActionResult> Create([Bind("PlayerId,Name,Dob,KitNumber,TeamId")] Player player)
        {
            // Validates and creates the object based on the given fields
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Team, "TeamId", "Name", player.TeamId);
            return(View(player));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("MatchId,Location,Date,LeagueId,HomeTeamId,AwayTeamId")] Match match)
        {
            // Validates and creates the object based on the given fields
            if (ModelState.IsValid)
            {
                _context.Add(match);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AwayTeamId"] = new SelectList(_context.Team, "TeamId", "Name", match.AwayTeamId);
            ViewData["HomeTeamId"] = new SelectList(_context.Team, "TeamId", "Name", match.HomeTeamId);
            ViewData["LeagueId"]   = new SelectList(_context.League, "LeagueId", "Year", match.LeagueId);
            return(View(match));
        }