Exemple #1
0
		public static MatchRaw ToMatchRaw(this Match source)
		{
			var match = new MatchRaw();
			match.ID = source.ID;
			match.EventID = source.EventID;
			match.LocationID = source.LocationID;
			match.Date = source.Date;
			match.WinnerID = source.WinnerID;
			match.LoserID = source.LoserID;
			match.Defaulted = source.Defaulted;
			match.Comments = source.Comments;

			match.WinnerSet1 = source.Score.Sets[0].Games.W;
			match.LoserSet1 = source.Score.Sets[0].Games.L;
			match.WinnerTiebreak1 = source.Score.Sets[0].Tiebreak.W;
			match.LoserTiebreak1 = source.Score.Sets[0].Tiebreak.L;

			if (source.Score.Sets.Count >= 2)
			{
				match.WinnerSet2 = source.Score.Sets[1].Games.W;
				match.LoserSet2 = source.Score.Sets[1].Games.L;
				match.WinnerTiebreak2 = source.Score.Sets[1].Tiebreak.W;
				match.LoserTiebreak2 = source.Score.Sets[1].Tiebreak.L;
			}

			if (source.Score.Sets.Count >= 3)
			{
				match.WinnerSet3 = source.Score.Sets[2].Games.W;
				match.LoserSet3 = source.Score.Sets[2].Games.L;
				match.WinnerTiebreak3 = source.Score.Sets[2].Tiebreak.W;
				match.LoserTiebreak3 = source.Score.Sets[2].Tiebreak.L;
			}

			if (source.Score.Sets.Count >= 4)
			{
				match.WinnerSet4 = source.Score.Sets[3].Games.W;
				match.LoserSet4 = source.Score.Sets[3].Games.L;
				match.WinnerTiebreak4 = source.Score.Sets[3].Tiebreak.W;
				match.LoserTiebreak4 = source.Score.Sets[3].Tiebreak.L;
			}

			if (source.Score.Sets.Count >= 5)
			{
				match.WinnerSet5 = source.Score.Sets[4].Games.W;
				match.LoserSet5 = source.Score.Sets[4].Games.L;
				match.WinnerTiebreak5 = source.Score.Sets[4].Tiebreak.W;
				match.LoserTiebreak5 = source.Score.Sets[4].Tiebreak.L;
			}

			return match;
		}
Exemple #2
0
		public void MatchRawToMatch(int id, int eventID, int winnerID, int loserID, string date, string score, bool defaulted)
		{
			var matchRaw = new MatchRaw();
			matchRaw.ID = id;
			matchRaw.EventID = eventID;
			matchRaw.WinnerID = winnerID;
			matchRaw.LoserID = loserID;
			matchRaw.Date = DateTime.Parse(date);
			var sets = score.parseMatchScore();

			matchRaw.WinnerSet1 = sets[0].Games.W;
			matchRaw.LoserSet1 = sets[0].Games.L;
			matchRaw.WinnerTiebreak1 = sets[0].Tiebreak.W;
			matchRaw.LoserTiebreak1 = sets[0].Tiebreak.L;

			if (sets.Count >= 2)
			{
				matchRaw.WinnerSet2 = sets[1].Games.W;
				matchRaw.LoserSet2 = sets[1].Games.L;
				matchRaw.WinnerTiebreak2 = sets[1].Tiebreak.W;
				matchRaw.LoserTiebreak2 = sets[1].Tiebreak.L;
			}

			if (sets.Count >= 3)
			{
				matchRaw.WinnerSet3 = sets[2].Games.W;
				matchRaw.LoserSet3 = sets[2].Games.L;
				matchRaw.WinnerTiebreak3 = sets[2].Tiebreak.W;
				matchRaw.LoserTiebreak3 = sets[2].Tiebreak.L;
			}

			if (sets.Count >= 4)
			{
				matchRaw.WinnerSet4 = sets[3].Games.W;
				matchRaw.LoserSet4 = sets[3].Games.L;
				matchRaw.WinnerTiebreak4 = sets[3].Tiebreak.W;
				matchRaw.LoserTiebreak4 = sets[3].Tiebreak.L;
			}

			if (sets.Count >= 5)
			{
				matchRaw.WinnerSet5 = sets[4].Games.W;
				matchRaw.LoserSet5 = sets[4].Games.L;
				matchRaw.WinnerTiebreak5 = sets[4].Tiebreak.W;
				matchRaw.LoserTiebreak5 = sets[4].Tiebreak.L;
			}

			matchRaw.Defaulted = false;

			var match = matchRaw.ToMatch();

			Assert.Equal(matchRaw.ID, match.ID);
			Assert.Equal(matchRaw.EventID, match.EventID);
			Assert.Equal(matchRaw.Date, match.Date);
			Assert.Equal(matchRaw.WinnerID, match.WinnerID);
			Assert.Equal(matchRaw.LoserID, match.LoserID);
			Assert.Equal(matchRaw.WinnerSet1, match.Score.Sets[0].Games.W);
			Assert.Equal(matchRaw.LoserSet1, match.Score.Sets[0].Games.L);
			Assert.Equal(matchRaw.WinnerSet2, match.Score.Sets[1].Games.W);
			Assert.Equal(matchRaw.LoserSet2, match.Score.Sets[1].Games.L);
		}