Example #1
0
        public async Task <ActionResult> DeleteMatch(Guid matchId)
        {
            var loginSession = HttpContext.GetLoginSession();
            var seasons      = await _seasonLogic.GetSeasons();

            var deleteCount = await _matchRepository.DeleteMatch(matchId, loginSession);

            if (deleteCount > 0)
            {
                foreach (Season season in seasons)
                {
                    await _leaderboardService.RecalculateLeaderboard(season);
                }
                return(Ok());
            }

            return(BadRequest());
        }
        public ActionResult Delete(Match match)
        {
            try
            {
                //Delete all related player matches
                List <PlayerMatch> playerMatches = _playerMatchRepository.GetPlayerMatchesByMatchId(match.ID).ToList();
                foreach (var playerMatch in playerMatches)
                {
                    _playerMatchRepository.DeletePlayerMatch(playerMatch);
                }

                _repository.DeleteMatch(match.ID);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                //error msg for failed delete in XML file
                ViewBag.ErrorMsg = "Error deleting record. " + ex.Message;
                return(View(_repository.GetMatchByID(match.ID)));
            }
        }
Example #3
0
        public async Task <ActionResult> DeleteMatch([Bind(Prefix = "ConfirmDeleteRequest", Include = "RequiredText,ConfirmationText")] MatchingTextConfirmation postedModel)
        {
            if (postedModel is null)
            {
                throw new ArgumentNullException(nameof(postedModel));
            }

            var model = new DeleteMatchViewModel(CurrentPage, Services.UserService)
            {
                Match             = await _matchDataSource.ReadMatchByRoute(Request.RawUrl).ConfigureAwait(false),
                DateTimeFormatter = _dateTimeFormatter
            };

            model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.Match);

            if (model.IsAuthorized[AuthorizedAction.DeleteMatch] && ModelState.IsValid)
            {
                var currentMember = Members.GetCurrentMember();
                await _matchRepository.DeleteMatch(model.Match, currentMember.Key, currentMember.Name).ConfigureAwait(false);

                await _cacheClearer.ClearCacheFor(model.Match).ConfigureAwait(false);

                model.Deleted = true;
            }
            else
            {
                model.TotalComments = await _matchCommentsDataSource.ReadTotalComments(model.Match.MatchId.Value).ConfigureAwait(false);
            }

            model.Metadata.PageTitle = "Delete " + model.Match.MatchFullName(x => _dateTimeFormatter.FormatDate(x, false, false, false)) + " - stoolball match";

            if (model.Match.Season != null)
            {
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = Constants.Pages.Competitions, Url = new Uri(Constants.Pages.CompetitionsUrl, UriKind.Relative)
                });
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = model.Match.Season.Competition.CompetitionName, Url = new Uri(model.Match.Season.Competition.CompetitionRoute, UriKind.Relative)
                });
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = model.Match.Season.SeasonName(), Url = new Uri(model.Match.Season.SeasonRoute, UriKind.Relative)
                });
            }
            else if (model.Match.Tournament != null)
            {
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = Constants.Pages.Tournaments, Url = new Uri(Constants.Pages.TournamentsUrl, UriKind.Relative)
                });
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = model.Match.Tournament.TournamentName, Url = new Uri(model.Match.Tournament.TournamentRoute, UriKind.Relative)
                });
            }
            else
            {
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = Constants.Pages.Matches, Url = new Uri(Constants.Pages.MatchesUrl, UriKind.Relative)
                });
            }
            if (!model.Deleted)
            {
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = model.Match.MatchName, Url = new Uri(model.Match.MatchRoute, UriKind.Relative)
                });
            }

            return(View("DeleteMatch", model));
        }
Example #4
0
 public Match DeleteMatch(int matchId)
 {
     return(_matchRepository.DeleteMatch(matchId));
 }
Example #5
0
 public IActionResult DeleteMatch(int matchId)
 {
     _matchRepository.DeleteMatch(matchId);
     return(Ok(null));
 }