[Authorize(Roles = AuthenticationRoles.AdministratorRole)] // Require authenticated requests. public async Task <HttpResponseMessage> Delete(int matchId) { Match match = await matchRepository.Get(matchId); if (!match.Played) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Cannot reset match not yet played")); } ScoreFilter scoreFilter = new ScoreFilter(); scoreFilter.MatchId = matchId; IEnumerable <Score> scores = await scoreRepository.GetAllWithFilter(scoreFilter); foreach (var score in scores) { score.Goals = 0; await scoreRepository.UpdateFromMatchResult(score); } match.Date = null; match.Played = false; await matchRepository.Update(matchId, match); return(Request.CreateResponse(HttpStatusCode.OK)); }
/// <summary> Copies the score filter from the given <paramref name="priorGeneration"/> into this generation's <see cref="ScoreFilter"/>, completely clearing the old values. </summary> /// <param name="priorGeneration"> The generation from which to copy. </param> public void SetFilterFrom(SeedGeneration priorGeneration) { // Clear the score filter. ScoreFilter.Clear(); // Copy each stat filter from the given generation's dictionary. foreach (string statName in priorGeneration.ScoreFilter.Keys) { ScoreFilter.Add(statName, priorGeneration.ScoreFilter[statName]); } }