From 70b5ea54f70d24fa03de61bb3a4d7315997d387b Mon Sep 17 00:00:00 2001 From: Darkstack <1835601+darkstack@users.noreply.github.com> Date: Sun, 7 Oct 2018 18:06:38 +0200 Subject: [PATCH] Generate Challonge --- LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs | 3 ++- LaDOSE.Src/LaDOSE.Entity/EventGame.cs | 2 ++ LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs | 3 ++- LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs | 6 +++--- LaDOSE.Src/LaDOSE.Service/Service/EventService.cs | 8 +++++++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs index 39b0bed..950fa97 100644 --- a/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs @@ -8,7 +8,8 @@ namespace LaDOSE.Entity.Context public DbSet ApplicationUser { get; set; } public DbSet Season { get; set; } public DbSet Event { get; set; } - //public DbSet SeasonGame { get; set; } + public DbSet SeasonGame { get; set; } + public DbSet EventGame { get; set; } public LaDOSEDbContext(DbContextOptions options) : base(options) { diff --git a/LaDOSE.Src/LaDOSE.Entity/EventGame.cs b/LaDOSE.Src/LaDOSE.Entity/EventGame.cs index 6c1bda9..0238a74 100644 --- a/LaDOSE.Src/LaDOSE.Entity/EventGame.cs +++ b/LaDOSE.Src/LaDOSE.Entity/EventGame.cs @@ -8,5 +8,7 @@ public int GameId { get; set; } public Game Game { get; set; } + public int? ChallongeId { get; set; } + public string ChallongeUrl { get; set; } } } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs b/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs index f46edc0..f8e4558 100644 --- a/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs +++ b/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using ChallongeCSharpDriver.Core.Results; namespace LaDOSE.Business.Interface { @@ -7,6 +8,6 @@ namespace LaDOSE.Business.Interface { Task GetLastTournament(); string GetLastTournamentMessage(); - Task> CreateTournament(string name, string url); + Task CreateTournament(string name, string url); } } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs b/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs index 4d00fe3..1b84b4c 100644 --- a/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs +++ b/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs @@ -28,10 +28,10 @@ namespace LaDOSE.Business.Provider DernierTournois = "Aucun tournois."; } - public async Task> CreateTournament(string name, string url) + public async Task CreateTournament(string name, string url) { - var p = await new CreateTournamentQuery(name, TournamentType.Double_Elimination, url).call(ApiCaller); - return new Tuple(p.id, p.url); + var result = await new CreateTournamentQuery(name, TournamentType.Double_Elimination, url).call(ApiCaller); + return result; } diff --git a/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs b/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs index 440937d..0022742 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs @@ -44,9 +44,15 @@ namespace LaDOSE.Business.Service { var url = $"TestDev{game.Id}{game.Name}"; var name = $"[{s}]Ranking {currentEvent.Name}{game.Name}"; - _challongeProvider.CreateTournament(name,url); + var tournament = _challongeProvider.CreateTournament(name,url).Result; + var eventGame = currentEvent.Games.FirstOrDefault(e => e.GameId == game.Id); + eventGame.ChallongeId = tournament.id; + eventGame.ChallongeUrl = tournament.url; + _context.Entry(eventGame).State = EntityState.Modified; + } + _context.SaveChanges(); return true; }