public async Task <ActionResult <TeamSeason> > DeleteTeamSeason(int id)
        {
            try
            {
                var teamSeason = await _teamSeasonRepository.GetTeamSeasonAsync(id);

                if (teamSeason is null)
                {
                    return(NotFound($"Could not find teamSeason with ID of {id}"));
                }

                await _teamSeasonRepository.DeleteAsync(id);

                if (await _sharedRepository.SaveChangesAsync() > 0)
                {
                    return(Ok());
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, Settings.DatabaseFailureString));
            }
        }
Exemple #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _teamSeasonRepository.DeleteAsync(id);

            await _sharedRepository.SaveChangesAsync();

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