Ejemplo n.º 1
0
        private MatchInfoBase extractMatchInfo(TableTennisTournamentMatchesVM matchDTO)
        {
            var settings = MatchInfoFactory.Instance.GetMatchInfoType <TableTennisMatchInfo>(MatchInfoType);

            settings.Sets1  = matchDTO.Sets1;
            settings.Sets2  = matchDTO.Sets2;
            settings.Result = matchDTO.Result;

            return(settings);
        }
Ejemplo n.º 2
0
        public List <TableTennisTournamentMatchesVM> GenerateMatchesViewModel(List <Match> matches, GroupPhaseSettings groupPhaseSettings)
        {
            List <TableTennisTournamentMatchesVM> matchesVM = new List <TableTennisTournamentMatchesVM>();

            foreach (var groupId in groupPhaseSettings.MatchIds.Keys)
            {
                foreach (var matchId in groupPhaseSettings.MatchIds[groupId])
                {
                    var match     = matches.First(x => x.Id == matchId);
                    var matchInfo = GetNewMatchInfo();
                    matchInfo.PopulateObject(match.MatchInfo);
                    var matchVM = new TableTennisTournamentMatchesVM()
                    {
                        MatchId       = match.Id,
                        CompetitorId1 = match.IdCompetitor1,
                        CompetitorId2 = match.IdCompetitor2,
                        Leg           = match.Leg,
                        Sets1         = matchInfo.Sets1,
                        Sets2         = matchInfo.Sets2,
                        Result        = matchInfo.Result,
                        GroupIndex    = groupId
                    };

                    if (matchVM.Sets1 == null)
                    {
                        matchVM.Sets1 = new List <string>()
                        {
                            null, null, null, null, null,
                        };
                    }

                    if (matchVM.Sets2 == null)
                    {
                        matchVM.Sets2 = new List <string>()
                        {
                            null, null, null, null, null,
                        };
                    }

                    matchesVM.Add(matchVM);
                }
            }

            return(matchesVM);
        }