Modification get smash
All checks were successful
Build App / Build (push) Successful in 1m53s

This commit is contained in:
2024-03-22 23:58:43 +01:00
parent 88fb4935b5
commit 454c12a5a9
19 changed files with 176 additions and 63 deletions

View File

@@ -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);

View File

@@ -18,6 +18,7 @@ namespace LaDOSE.Business.Interface
Task<TournamentResponse> GetNames(string slug);
Task<List<Game>> GetGames(string name);
}
}

View File

@@ -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)
{

View File

@@ -120,7 +120,10 @@ namespace LaDOSE.Business.Provider.SmashProvider
}
public class VideoGamesResponse
{
public Node<VideoGameType>? videogames {get; set; }
}
public class TournamentResponse

View File

@@ -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);