Exemple #1
0
        public string GetScoresCsv(Match match)
        {
            string scoringFormat = string.Empty;
            if (match.Player1Id == HomePlayerId)
                scoringFormat = "{0}-{1}";
            else
                scoringFormat = "{1}-{0}";

            StringBuilder scores = new StringBuilder();
            for (int index = 0; index < HomePlayerScores.Length; index++)
            {
                if(index > 0)
                    scores.Append(",");
                scores.AppendFormat(scoringFormat, HomePlayerScores[index], AwayPlayerScores[index]);
            }
            return scores.ToString();
        }
Exemple #2
0
        public static MatchModel Create(Match match, IList<Participant> participants)
        {
            var model = new MatchModel();
            model.Player1 = PlayerModel.Create(participants.Where(p => p.Id == match.Player1Id).First());
            model.Player2 = PlayerModel.Create(participants.Where(p => p.Id == match.Player2Id).First());

            if (!string.IsNullOrEmpty(match.ScoresCsv))
            {
                var matchArr = match.ScoresCsv.Split('-');
                model.ScorePlayer1 = int.Parse(matchArr[0]);
                model.ScorePlayer2 = int.Parse(matchArr[1]);
            }

            model.Played = match.State == "complete";

            model.Round = match.Round.Value;

            return model;
        }