Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("MatchId,SeasonId,MatchDate,Location,MatchDetail")] Match match)
        {
            if (ModelState.IsValid)
            {
                _context.Add(match);
                await _context.SaveChangesAsync();

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

            var leagues = await _context.Leagues.ToListAsync();

            var seasons = await _context.Seasons
                          .Include(s => s.Teams)
                          .Where(m => m.LeagueId == leagues.First().LeagueId)
                          .ToListAsync();

            var view = new CreateEditMatchViewModel()
            {
                Seasons = seasons,
                Leagues = leagues,
                Match   = match
            };

            return(View(view));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("SeasonId,LeagueId,Name,IsActive")] Season season)
        {
            if (ModelState.IsValid)
            {
                _context.Add(season);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(season));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("LeagueId,Name")] League league)
        {
            if (ModelState.IsValid)
            {
                _context.Add(league);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(league));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("TeamId,SeasonId,Name")] Team team)
        {
            if (ModelState.IsValid)
            {
                _context.Add(team);
                await _context.SaveChangesAsync();

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