public async Task <IActionResult> Create(int leagueId, [Bind("Id,Name")] Season season)
        {
            var league = await leagueRepository.FindLeagueForIdAndUser(leagueId, await getCurrentUserId());

            if (ModelState.IsValid && league != null)
            {
                season.League = league;
                await seasonRepository.CreateSeason(season);

                return(RedirectToAction(nameof(Index), new { leagueId }));
            }
            return(View(season));
        }
Exemplo n.º 2
0
        public async Task deleteEntireLeague(int id, string userId)
        {
            var league = await leagueRepository.FindLeagueForIdAndUser(id, userId);

            IList <Season> seasonsToRemove = new List <Season>();

            foreach (var season in league.Seasons)
            {
                await deleteSeasonRelevantInformation(season);
            }
            await seasonRepository.deleteMany(league.Seasons);

            await leagueRepository.DeleteLeague(id);
        }