Skip to content

Commit

Permalink
Uploaderiin tuki playoffille
Browse files Browse the repository at this point in the history
  • Loading branch information
arttuka committed Jul 22, 2018
1 parent 8142acf commit 5f6c638
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ orderby match.table

return OleDbFetch<Round>(
r => new Round(Convert.ToInt32(r["Number"]),
Convert.ToBoolean(r["IsPlayoff"]),
pairingsByRound[Convert.ToInt32(r["RoundId"])].ToImmutableList()),
"SELECT Round.RoundId, Round.Number " +
"SELECT Round.RoundId, Round.Number, Round.IsPlayoff " +
"FROM Round " +
"WHERE (Round.TournamentId = ?)",
new object[] {tournamentId}).OrderBy(r => r.Number).ToImmutableList();
Expand Down
5 changes: 4 additions & 1 deletion mtg-pairings-win/MtgPairings/MtgPairings/Domain/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ public class Round
{
public int Number { get; private set; }
public ImmutableList<Pairing> Pairings { get; private set; }
public bool Playoff { get; private set; }

public Round(int number, ImmutableList<Pairing> pairings)
public Round(int number, bool playoff, ImmutableList<Pairing> pairings)
{
Number = number;
Playoff = playoff;
Pairings = pairings;
}

Expand All @@ -32,6 +34,7 @@ public bool Equals(Round other)
else
{
return this.Number == other.Number &&
this.Playoff == other.Playoff &&
this.Pairings.SequenceEqual(other.Pairings);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void CheckTournaments()
{
if (round.OldRound == null || round.NewRound == null || !round.OldRound.Pairings.SequenceEqual(round.NewRound.Pairings, new Pairing.PairingEqualityComparer()) || round.NewRound != null && uploadAll)
{
UploadEvent e = new UploadEvent(() => _uploader.UploadPairings(newTournament.SanctionNumber, round.NewRound.Number, round.NewRound.Pairings),
UploadEvent e = new UploadEvent(() => _uploader.UploadPairings(newTournament.SanctionNumber, round.NewRound.Number, round.NewRound.Playoff, round.NewRound.Pairings),
t.AutoUpload, newTournament, UploadEvent.Type.Pairings, round.NewRound.Number);
UploadQueue.Enqueue(e);
uploadAll = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
5 changes: 3 additions & 2 deletions mtg-pairings-win/MtgPairings/MtgPairings/Service/Uploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,16 @@ public void DeleteRound(string sanctionid, int round)
Execute(request);
}

public void UploadPairings(string sanctionid, int round, IEnumerable<Pairing> pairings)
public void UploadPairings(string sanctionid, int round, bool playoff, IEnumerable<Pairing> pairings)
{
var request = createRequest("api/tournament/{sanctionid}/round-{round}/pairings", Method.PUT,
new {
pairings = pairings.Select(p => new {
team1 = p.Team1.Players.Select(player => player.DciNumber),
team2 = p.Team2.Select(t => t.Players.Select(player => player.DciNumber)).ValueOrElse(Enumerable.Empty<string>()),
table_number = p.Table
})
}),
playoff = playoff
});
request.AddParameter("sanctionid", sanctionid, ParameterType.UrlSegment);
request.AddParameter("round", round, ParameterType.UrlSegment);
Expand Down

0 comments on commit 5f6c638

Please sign in to comment.