This commit is contained in:
@@ -10,6 +10,9 @@ namespace LaDOSE.Business.Interface
|
||||
{
|
||||
Task<List<ChallongeTournament>> GetTournaments(DateTime? start, DateTime? end);
|
||||
Task<Event> ParseSmash(string tournamentSlug);
|
||||
|
||||
Task<List<Game>> GetSmashGame(string name);
|
||||
|
||||
//Task<List<Event>> ParseChallonge(List<int> ids);
|
||||
|
||||
//Task<TournamentsResult> GetChallongeTournamentsResult(List<int> ids);
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace LaDOSE.Business.Interface
|
||||
|
||||
Task<TournamentResponse> GetNames(string slug);
|
||||
|
||||
Task<List<Game>> GetGames(string name);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,37 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
return graphQLResponse.Data;
|
||||
}
|
||||
|
||||
public async Task<List<Game>> GetGames(string game)
|
||||
{
|
||||
var query = new GraphQLRequest()
|
||||
{
|
||||
Query = @"
|
||||
query VideogameQuery($name:String) {
|
||||
videogames(query: { filter: { name: $name }, perPage: 5 }) {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
",
|
||||
OperationName = "VideogameQuery",
|
||||
Variables = new
|
||||
{
|
||||
name = game,
|
||||
}
|
||||
};
|
||||
VideoGamesResponse querySmash = await QuerySmash<VideoGamesResponse>(query);
|
||||
if (querySmash.videogames != null)
|
||||
{
|
||||
return querySmash.videogames.nodes.Select(e => new Game() { Id = e.id, Name = e.Name }).ToList();
|
||||
}
|
||||
|
||||
return new List<Game>();
|
||||
|
||||
}
|
||||
|
||||
public async Task<Event> GetEvent(string slug)
|
||||
{
|
||||
|
||||
|
||||
@@ -120,7 +120,10 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class VideoGamesResponse
|
||||
{
|
||||
public Node<VideoGameType>? videogames {get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class TournamentResponse
|
||||
|
||||
@@ -78,6 +78,10 @@ namespace LaDOSE.Business.Service
|
||||
//}
|
||||
}
|
||||
|
||||
public async Task<List<Game>> GetSmashGames(string name)
|
||||
{
|
||||
return await _smashProvider.GetGames(name);
|
||||
}
|
||||
public async Task<Event> ParseSmash(string tournamentSlug)
|
||||
{
|
||||
Event eventExist = GetBySlug(tournamentSlug);
|
||||
@@ -109,6 +113,11 @@ namespace LaDOSE.Business.Service
|
||||
|
||||
}
|
||||
|
||||
public Task<List<Game>> GetSmashGame(string name)
|
||||
{
|
||||
return _smashProvider.GetGames(name);
|
||||
}
|
||||
|
||||
private Event GetBySlug(string tournamentSlug)
|
||||
{
|
||||
return _context.Event.FirstOrDefault(e => e.SmashSlug == tournamentSlug);
|
||||
|
||||
Reference in New Issue
Block a user