Exemple #1
0
        public async Task <ActionResult <TeamSeason> > DeleteLeague(int id)
        {
            try
            {
                var league = await _leagueRepository.GetLeagueAsync(id);

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

                await _leagueRepository.DeleteAsync(id);

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

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

            await _sharedRepository.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemple #3
0
        public async Task <ResponseDto <BaseModelDto> > DeleteLeague(int leagueId)
        {
            var response = new ResponseDto <BaseModelDto>();

            var league = _leagueRepository.GetById(leagueId);

            if (league == null)
            {
                response.Errors.Add(ServiceErrors.LEAGUE_DOESNT_EXIST);
                return(response);
            }

            await _leagueRepository.DeleteAsync(league);

            return(response);
        }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var model = await _leagueRepository.DeleteAsync(id.Value);

            if (model == null)
            {
                Response.StatusCode = 404;
                return(View("LeagueNotFound", id.Value));
            }

            return(RedirectToAction("Index"));
        }
Exemple #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id is null)
            {
                return(NotFound());
            }

            League = await _leagueRepository.GetLeagueAsync(id.Value);

            if (!(League is null))
            {
                await _leagueRepository.DeleteAsync(League.ID);

                await _sharedRepository.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }