public void UpdateCompetitionPhaseSettings(CompetitionPhase competitionPhase, CompetitionAdvancedOptionsDTO advancedOptions, Dictionary <int, List <Match> > matches, JArray competitorAllocations, Dictionary <int, Competitor> competitorLookup) { switch (advancedOptions.CompetitionPhaseType) { case CompetitionPhaseTypeEnum.Table: updateTableCompetitionPhaseSettings(competitionPhase, advancedOptions, matches, competitorAllocations, competitorLookup); break; case CompetitionPhaseTypeEnum.Knockout: throw new NotImplementedException(); default: throw new Exception("Type not supported"); } }
private void updateTableCompetitionPhaseSettings(CompetitionPhase competitionPhase, CompetitionAdvancedOptionsDTO advancedOptions, Dictionary <int, List <Match> > matches, JArray competitorAllocations, Dictionary <int, Competitor> competitorLookup) { var competitionSettings = new GroupPhaseSettings(); if (!string.IsNullOrEmpty(competitionPhase.Settings)) { competitionSettings.PopulateObject(competitionPhase.Settings); } Dictionary <int, List <int> > matchIds = new Dictionary <int, List <int> >(); foreach (var groupMathces in matches) { matchIds.Add(groupMathces.Key, new List <int>()); matchIds[groupMathces.Key].AddRange(groupMathces.Value.Select(x => x.Id)); } competitionSettings.MatchIds = matchIds; competitionSettings.CompetitorIds = getCompetitorsGroupedByGroup(competitorAllocations, competitorLookup); competitionSettings.MatchInfoType = advancedOptions.MatchInfoType; competitionSettings.CompetitorPhaseInfoType = advancedOptions.CompetititorInfoType; competitionPhase.Settings = competitionSettings.SerializeObject(); }