Modification Smash
Ajout Ecran Layout XSB
This commit is contained in:
@@ -18,5 +18,6 @@ namespace LaDOSE.Business.Interface
|
||||
Task<List<Event>> GetChallongeEvents(List<int> ids);
|
||||
|
||||
Task<TournamentsResult> GetEventsResult(List<int> ids);
|
||||
Task<List<String>> GetPlayer(string slug);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,8 @@ namespace LaDOSE.Business.Interface
|
||||
Task<Event> ParseEvent(string slug);
|
||||
Task<TournamentResponse> GetTournament(string sludge);
|
||||
|
||||
Task<TournamentResponse> GetNames(string slug);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -47,8 +47,6 @@ namespace LaDOSE.Business.Provider.ChallongProvider
|
||||
{
|
||||
var result = await new CreateTournamentQuery(name, startAt, TournamentType.Double_Elimination, url).call(ApiCaller);
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<ParticipantResult> AddPlayer(int tournamentId, string userName)
|
||||
@@ -56,7 +54,6 @@ namespace LaDOSE.Business.Provider.ChallongProvider
|
||||
var p = new ParticipantEntry(userName);
|
||||
var result = await new AddParticipantQuery(tournamentId, p).call(ApiCaller);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<ChallongeTournament>> GetTournaments(DateTime? start, DateTime? end)
|
||||
@@ -119,6 +116,7 @@ namespace LaDOSE.Business.Provider.ChallongProvider
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public async Task<ChallongeTournament> GetTournament(string urlTournament)
|
||||
{
|
||||
|
||||
|
||||
@@ -307,6 +307,74 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<TournamentResponse> GetNames(string slug)
|
||||
{
|
||||
|
||||
var graphQLClient = new GraphQLHttpClient("https://api.smash.gg/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
var Event = new GraphQLRequest
|
||||
{
|
||||
Query = @"query TournamentQuery($slug: String) {
|
||||
tournament(slug: $slug){
|
||||
id
|
||||
|
||||
name
|
||||
|
||||
events {
|
||||
id
|
||||
|
||||
name,
|
||||
state,
|
||||
videogame {
|
||||
id,
|
||||
name,
|
||||
displayName
|
||||
},
|
||||
entrants{
|
||||
nodes{
|
||||
id
|
||||
name,
|
||||
participants{
|
||||
id,
|
||||
gamerTag
|
||||
player{
|
||||
gamerTag
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
}"
|
||||
,
|
||||
OperationName = "TournamentQuery",
|
||||
Variables = new
|
||||
{
|
||||
slug = slug,
|
||||
}
|
||||
};
|
||||
|
||||
//GraphQLHttpRequest preprocessedRequest = await graphQLClient.Options.PreprocessRequest(EventType, graphQLClient);
|
||||
//var x = preprocessedRequest.ToHttpRequestMessage(graphQLClient.Options, new NewtonsoftJsonSerializer());
|
||||
//System.Diagnostics.Trace.WriteLine(x.Content.ReadAsStringAsync().Result);
|
||||
//var sendAsync = await graphQLClient.HttpClient.SendAsync(x);
|
||||
//System.Diagnostics.Trace.WriteLine(sendAsync.Content.ReadAsStringAsync().Result);
|
||||
|
||||
var graphQLResponse = await graphQLClient.SendQueryAsync<TournamentResponse>(Event);
|
||||
if (graphQLResponse.Errors != null)
|
||||
{
|
||||
//EventType not done ?
|
||||
//throw new Exception("Error");
|
||||
}
|
||||
System.Diagnostics.Trace.Write(graphQLResponse.Data.Tournament.Name);
|
||||
|
||||
return graphQLResponse.Data;
|
||||
}
|
||||
|
||||
|
||||
public async Task<TournamentResponse> GetTournament(string slug)
|
||||
{
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
public VideoGameType videogame { get; set; }
|
||||
public Node<StandingType> standings { get; set; }
|
||||
public Node<SetType> sets { get; set; }
|
||||
|
||||
public Node<EntrantType> entrants { get; set; }
|
||||
}
|
||||
|
||||
public class EntrantType
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Reactive.Subjects;
|
||||
using System.Threading.Tasks;
|
||||
using LaDOSE.Business.Helper;
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Business.Provider.SmashProvider;
|
||||
using LaDOSE.Entity;
|
||||
using LaDOSE.Entity.Challonge;
|
||||
using LaDOSE.Entity.Context;
|
||||
@@ -206,7 +207,7 @@ namespace LaDOSE.Business.Service
|
||||
// var parse = await this.ParseSmash(tournamentSlug);
|
||||
// var test = await GetEventResult(parse.Id);
|
||||
// return test;
|
||||
|
||||
|
||||
//}
|
||||
|
||||
//public async Task<TournamentsResult> GetEventsResult(List<int> events)
|
||||
@@ -279,7 +280,7 @@ namespace LaDOSE.Business.Service
|
||||
players = players.Concat(e.Tournaments.SelectMany(e => e.Results.Select(e => e.Player)).Distinct().ToList()).ToList();
|
||||
cevent.Tournaments = cevent.Tournaments.Concat(e.Tournaments).ToList();
|
||||
}
|
||||
|
||||
|
||||
var games = _context.Game.ToList();
|
||||
|
||||
TournamentsResult result = new TournamentsResult();
|
||||
@@ -360,6 +361,15 @@ namespace LaDOSE.Business.Service
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetPlayer(string slug)
|
||||
{
|
||||
var tournament = await _smashProvider.GetNames(slug);
|
||||
var players = tournament.Tournament.Events.SelectMany(e => e.entrants.nodes.SelectMany(x => x.participants.Select(e => e.gamerTag))).ToList();
|
||||
return players;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Result For one Event
|
||||
/// </summary>
|
||||
@@ -367,8 +377,8 @@ namespace LaDOSE.Business.Service
|
||||
/// <returns></returns>
|
||||
public async Task<TournamentsResult> GetEventResult(int id)
|
||||
{
|
||||
|
||||
Event cevent = _context.Event.Include(e=>e.Tournaments).ThenInclude(t=>t.Results).ThenInclude(e=>e.Player).FirstOrDefault(e => e.Id == id);
|
||||
|
||||
Event cevent = _context.Event.Include(e => e.Tournaments).ThenInclude(t => t.Results).ThenInclude(e => e.Player).FirstOrDefault(e => e.Id == id);
|
||||
var players = cevent.Tournaments.SelectMany(e => e.Results.Select(e => e.Player)).Distinct().ToList();
|
||||
var games = _context.Game.ToList();
|
||||
|
||||
@@ -407,18 +417,18 @@ namespace LaDOSE.Business.Service
|
||||
var Top8 = tournament.Results.Where(p => p.Rank > 4 && p.Rank < 9).ToList();
|
||||
var Top16 = tournament.Results.Where(p => p.Rank > 8 && p.Rank <= 16).ToList();
|
||||
|
||||
result.Results.Add(new Result(first.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name, currentRule.FirstPoint, first.Rank));
|
||||
result.Results.Add(new Result(first.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name, currentRule.FirstPoint, first.Rank));
|
||||
lesSacs.Remove(first.Player);
|
||||
result.Results.Add(new Result(second.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name, currentRule.SecondPoint, second.Rank));
|
||||
lesSacs.Remove(second.Player);
|
||||
thirdFourth.ForEach(r =>
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.ThirdFourthPoint, r.Rank)));
|
||||
thirdFourth.ForEach(p => lesSacs.Remove(p.Player));
|
||||
if (currentRule.Top8Point != 0)
|
||||
{
|
||||
Top8.ForEach(r =>
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.Top8Point, r.Rank)));
|
||||
Top8.ForEach(p => lesSacs.Remove(p.Player));
|
||||
}
|
||||
@@ -427,20 +437,20 @@ namespace LaDOSE.Business.Service
|
||||
{
|
||||
Top16.ForEach(r =>
|
||||
result.Results.Add(
|
||||
new Result(r.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
new Result(r.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.Top16Point, r.Rank)));
|
||||
Top16.ForEach(p => lesSacs.Remove(p.Player));
|
||||
}
|
||||
|
||||
lesSacs.ForEach(r =>
|
||||
result.Results.Add(new Result(r.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
currentRule.Participation, tournament.Results.FirstOrDefault(e=>e.Player == r)?.Rank??999)));
|
||||
result.Results.Add(new Result(r.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.Participation, tournament.Results.FirstOrDefault(e => e.Player == r)?.Rank ?? 999)));
|
||||
|
||||
}
|
||||
|
||||
if (result.Results.Any(e => e.GameId == 0))
|
||||
{
|
||||
result.Games.Add(new Game(){Id = 0,Name = "GAME NOT FOUND",LongName = "GAME NOT FOUND",Order = 999});
|
||||
result.Games.Add(new Game() { Id = 0, Name = "GAME NOT FOUND", LongName = "GAME NOT FOUND", Order = 999 });
|
||||
}
|
||||
|
||||
var enumerable = result.Results.Select(e => e.GameId).Distinct();
|
||||
|
||||
Reference in New Issue
Block a user