Added search options for tournament result + small test

This commit is contained in:
2019-05-28 00:20:02 +02:00
parent 80893e55de
commit 1f5961cdd0
7 changed files with 41 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using AutoMapper;
using LaDOSE.Business.Interface;
using LaDOSE.DTO;
@@ -89,5 +91,13 @@ namespace LaDOSE.Api.Controllers
{
return _service.CreateChallonge(gameId, wpEventId, additionalPlayer);
}
[HttpGet("GetTournaments")]
public async Task<List<Tuple<int, string, string>>> GetChallonge()
{
var game = await _service.GetTournaments(DateTime.Now.AddMonths(-2), null);
return game;
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ChallongeCSharpDriver.Core.Results;
@@ -10,5 +11,7 @@ namespace LaDOSE.Business.Interface
string GetLastTournamentMessage();
Task<TournamentResult> CreateTournament(string name, string url);
Task<ParticipantResult> AddPlayer(int tournamentId, string userName);
Task<List<TournamentResult>> GetTournaments(DateTime? start, DateTime? end);
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LaDOSE.Entity;
using LaDOSE.Entity.Wordpress;
@@ -15,5 +16,7 @@ namespace LaDOSE.Business.Interface
string CreateChallonge(int gameId, int wpEventId, IList<WPUser> additionPlayers);
Task<string> GetLastChallonge();
Task<List<Tuple<int, string, string>>> GetTournaments(DateTime? start, DateTime? end);
}
}

View File

@@ -12,8 +12,7 @@
<ItemGroup>
<Reference Include="ChallongeCSharpDriver">
<HintPath>..\Libraries\ChallongeCSharpDriver.dll</HintPath>
<Private>true</Private>
<HintPath>..\..\..\..\..\Project\LaDOSE\LaDOSE\Library\ChallongeCSharpDriver.dll</HintPath>
</Reference>
</ItemGroup>

View File

@@ -45,6 +45,21 @@ namespace LaDOSE.Business.Provider
}
public async Task<List<TournamentResult>> GetTournaments(DateTime? start, DateTime? end)
{
List<TournamentResult> tournamentResultList = await new TournamentsQuery()
{
state = TournamentState.Ended,
createdAfter = start,
createdBefore = DateTime.Now,
}
.call(this.ApiCaller);
return tournamentResultList;
}
public async Task<string> GetLastTournament()
{
string dernierTournois = null;

View File

@@ -164,7 +164,13 @@ namespace LaDOSE.Business.Service
var lastTournament = await _challongeProvider.GetLastTournament();
return lastTournament;
}
public async Task<List<Tuple<int, string, string>>> GetTournaments(DateTime? start, DateTime? end)
{
var tournamentResults = await _challongeProvider.GetTournaments(start,end);
List<Tuple<int,string,string>> ret = new List<Tuple<int, string,string>>();
tournamentResults.ForEach(w =>ret.Add(new Tuple<int, string,string>(w.id,w.name,w.url)));
return ret;
}
private string FormatCurrentEventName(string currentEventName)
{