diff --git a/LaDOSE.Src/LaDOSE.Api/Controllers/SeasonController.cs b/LaDOSE.Src/LaDOSE.Api/Controllers/SeasonController.cs deleted file mode 100644 index d24b430..0000000 --- a/LaDOSE.Src/LaDOSE.Api/Controllers/SeasonController.cs +++ /dev/null @@ -1,18 +0,0 @@ -using LaDOSE.Business.Interface; -using LaDOSE.Business.Service; -using LaDOSE.Entity; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace LaDOSE.Api.Controllers -{ - [Authorize] - [Route("api/[controller]")] - [Produces("application/json")] - public class SeasonController : GenericController - { - public SeasonController(ISeasonService service) : base(service) - { - } - } -} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Api/Controllers/SmashController.cs b/LaDOSE.Src/LaDOSE.Api/Controllers/SmashController.cs index a4f34b1..5c6262f 100644 --- a/LaDOSE.Src/LaDOSE.Api/Controllers/SmashController.cs +++ b/LaDOSE.Src/LaDOSE.Api/Controllers/SmashController.cs @@ -44,18 +44,6 @@ namespace LaDOSE.Api.Controllers return null; } - //[HttpPost("GetResults")] - //public async Task GetResults([FromBody] List ids) - //{ - // if (ids == null) - // { - // throw new Exception("Invalid arguments"); - // } - - // var tournamentsResult = await _service.GetTournamentsResult(ids); - // return _mapper.Map(tournamentsResult); - - //} } diff --git a/LaDOSE.Src/LaDOSE.Api/Startup.cs b/LaDOSE.Src/LaDOSE.Api/Startup.cs index 6b6cd94..bd6981c 100644 --- a/LaDOSE.Src/LaDOSE.Api/Startup.cs +++ b/LaDOSE.Src/LaDOSE.Api/Startup.cs @@ -30,6 +30,7 @@ using LaDOSE.Business.Provider.ChallongProvider; using LaDOSE.Business.Provider.SmashProvider; using LaDOSE.Entity.Challonge; using LaDOSE.Entity.Wordpress; +using Result = LaDOSE.Entity.Challonge.Result; namespace LaDOSE.Api { @@ -146,7 +147,6 @@ namespace LaDOSE.Api services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs b/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs index 0908dde..6ec3202 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/App.xaml.cs @@ -19,14 +19,15 @@ namespace LaDOSE.DesktopApp { #if DEBUG - MessageBox.Show("WAITING IN DEBUG MODE"); + MessageBox.Show("WAITING IN DEBUG MODE"); #endif - base.OnStartup(e); - var settings = new CefSettings(); settings.SetOffScreenRenderingBestPerformanceArgs(); Cef.Initialize(settings); + base.OnStartup(e); + + } diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs index 64db6f9..20ac84d 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Bootstrapper.cs @@ -26,7 +26,6 @@ namespace LaDOSE.DesktopApp container.Singleton(); container.Singleton(); - container.PerRequest(); diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs index 7be5531..efd11c9 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/ShellViewModel.cs @@ -31,7 +31,7 @@ namespace LaDOSE.DesktopApp.ViewModels this.AppIcon = BitmapFrame.Create(Application.GetResourceStream(new Uri("/LaDOSE.DesktopApp;component/Resources/64x64.png", UriKind.RelativeOrAbsolute)).Stream); - + var appSettings = ConfigurationManager.AppSettings; string url = (string)appSettings["ApiUri"]; string user = (string)appSettings["ApiUser"]; @@ -41,9 +41,10 @@ namespace LaDOSE.DesktopApp.ViewModels restService.UpdatedJwtEvent += TokenUpdate; restService.Connect(uri, user, password); + base.OnInitialize(); - - + ActivateItem(new TournamentResultViewModel(IoC.Get())); + } private void TokenUpdate(object sender, UpdatedJwtEventHandler e) @@ -56,7 +57,7 @@ namespace LaDOSE.DesktopApp.ViewModels public void LoadEvent() { - ActivateItem(new WordPressViewModel(IoC.Get())); + ActivateItem(new WordPressViewModel(IoC.Get())); } public void LoadGames() { diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs index 1586133..32fe7c9 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs @@ -344,7 +344,13 @@ namespace LaDOSE.DesktopApp.ViewModels int columns = 0; foreach (var game in Results.Games) { - + List enumerable = Results.Results.Where(r => r.GameId == game.Id).ToList(); + List top3 = enumerable.OrderBy(e => e.Rank).Take(3).Select(e => e.Player).ToList(); + if (top3.Count == 0) + { + continue; + } + if (columns % 2 == 0) { sb.Append(""); @@ -354,8 +360,7 @@ namespace LaDOSE.DesktopApp.ViewModels "" + $"{game.LongName} ({Results.Results.Count(e => e.GameId == game.Id)} participants) :" + ""); - List enumerable = Results.Results.Where(r => r.GameId == game.Id).ToList(); - List top3 = enumerable.OrderBy(e => e.Rank).Take(3).Select(e => e.Player).ToList(); + if (top3.Count >= 3) { sb.AppendLine($"
1/ {top3[0]}
2/ {top3[1]}
3/ {top3[2]}
"); diff --git a/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs index 158e8d4..ea866fd 100644 --- a/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs @@ -1,4 +1,5 @@ using LaDOSE.Entity.Challonge; + using LaDOSE.Entity.Wordpress; using Microsoft.EntityFrameworkCore; @@ -8,19 +9,25 @@ namespace LaDOSE.Entity.Context { public DbSet Game { get; set; } public DbSet ApplicationUser { get; set; } - public DbSet Season { get; set; } - public DbSet Event { get; set; } + public DbSet Todo { get; set; } #region WordPress public DbSet WPUser { get; set; } public DbSet WPEvent { get; set; } public DbSet WPBooking { get; set; } - + + + #endregion + + + #region Tournament + public DbSet Player { get; set; } + public DbSet Event { get; set; } + public DbSet Tournament { get; set; } + public DbSet Result { get; set; } #endregion - public DbSet SeasonGame { get; set; } - public DbSet EventGame { get; set; } public DbSet ChallongeParticipent { get; set; } public DbSet ChallongeTournament { get; set; } @@ -36,43 +43,43 @@ namespace LaDOSE.Entity.Context - modelBuilder.Entity() - .HasOne(s => s.Season) - .WithMany(p => p.Event) - .HasForeignKey(fk => fk.SeasonId); + //modelBuilder.Entity() + // .HasOne(s => s.Season) + // .WithMany(p => p.Event) + // .HasForeignKey(fk => fk.SeasonId); - #region SeasonGame - modelBuilder.Entity() - .HasKey(t => new { t.SeasonId, t.GameId }); + //#region SeasonGame + //modelBuilder.Entity() + // .HasKey(t => new { t.SeasonId, t.GameId }); - modelBuilder.Entity() - .HasOne(pt => pt.Season) - .WithMany(p => p.Games) - .HasForeignKey(pt => pt.SeasonId); + //modelBuilder.Entity() + // .HasOne(pt => pt.Season) + // .WithMany(p => p.Games) + // .HasForeignKey(pt => pt.SeasonId); - modelBuilder.Entity() - .HasOne(pt => pt.Game) - .WithMany(p => p.Seasons) - .HasForeignKey(pt => pt.GameId); - #endregion + //modelBuilder.Entity() + // .HasOne(pt => pt.Game) + // .WithMany(p => p.Seasons) + // .HasForeignKey(pt => pt.GameId); + //#endregion - #region EventGame + //#region EventGame - modelBuilder.Entity() - .HasKey(t => new { t.EventId, t.GameId }); + //modelBuilder.Entity() + // .HasKey(t => new { t.EventId, t.GameId }); - modelBuilder.Entity() - .HasOne(pt => pt.Event) - .WithMany(p => p.Games) - .HasForeignKey(pt => pt.EventId); + //modelBuilder.Entity() + // .HasOne(pt => pt.Event) + // .WithMany(p => p.Games) + // .HasForeignKey(pt => pt.EventId); - modelBuilder.Entity() - .HasOne(pt => pt.Game) - .WithMany(p => p.Events) - .HasForeignKey(pt => pt.GameId); - #endregion + //modelBuilder.Entity() + // .HasOne(pt => pt.Game) + // .WithMany(p => p.Events) + // .HasForeignKey(pt => pt.GameId); + //#endregion #region WordPress WPBooking diff --git a/LaDOSE.Src/LaDOSE.Entity/Event.cs b/LaDOSE.Src/LaDOSE.Entity/Event.cs deleted file mode 100644 index 86126b2..0000000 --- a/LaDOSE.Src/LaDOSE.Entity/Event.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace LaDOSE.Entity -{ - public class Event : Context.Entity - { - //[Key] - //public int Id { get; set; } - public string Name { get; set; } - public DateTime Date { get; set; } - public int SeasonId { get; set; } - public Season Season { get; set; } - public bool Ranking { get; set; } - - - public virtual IEnumerable Games { get; set; } - - - } -} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/EventGame.cs b/LaDOSE.Src/LaDOSE.Entity/EventGame.cs deleted file mode 100644 index afce7a1..0000000 --- a/LaDOSE.Src/LaDOSE.Entity/EventGame.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace LaDOSE.Entity -{ - public class EventGame - { - - public int EventId { get; set; } - public Event Event { get; set; } - 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.Entity/Game.cs b/LaDOSE.Src/LaDOSE.Entity/Game.cs index dc4735f..206f1a0 100644 --- a/LaDOSE.Src/LaDOSE.Entity/Game.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Game.cs @@ -13,16 +13,8 @@ namespace LaDOSE.Entity public string WordPressTagOs { get; set; } public int? SmashId { get; set; } - public virtual IEnumerable Seasons { get; set; } - public virtual IEnumerable Events { get; set; } - - } - public class SmashParticipent : Context.Entity - { - public string Name { get; set; } - public string Tag { get; set; } - public int? SmashId{ get; set; } - + } + } diff --git a/LaDOSE.Src/LaDOSE.Entity/Season.cs b/LaDOSE.Src/LaDOSE.Entity/Season.cs deleted file mode 100644 index 0261d98..0000000 --- a/LaDOSE.Src/LaDOSE.Entity/Season.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace LaDOSE.Entity -{ - public class Season : Context.Entity - { - - public string Name { get; set; } - - public DateTime StartDate { get; set; } - public DateTime EndDate { get; set; } - - public virtual IEnumerable Games { get; set; } - - public virtual IEnumerable Event { get; set; } - } -} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/SeasonGame.cs b/LaDOSE.Src/LaDOSE.Entity/SeasonGame.cs deleted file mode 100644 index 9b42d36..0000000 --- a/LaDOSE.Src/LaDOSE.Entity/SeasonGame.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace LaDOSE.Entity -{ - public class SeasonGame - { - public int GameId { get; set; } - public Game Game { get; set; } - public int SeasonId { get; set; } - public Season Season { get; set; } - - } -} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Event.cs b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Event.cs new file mode 100644 index 0000000..89272b0 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Event.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +namespace LaDOSE.Entity +{ + /// + /// Represent a Event (Multiple tournaments) + /// + public class Event : Context.Entity + { + public Event() + { + } + + public Event(string name,int? smashId) + { + Name = name; + SmashId = smashId; + } + + public String Name { get; set; } + public int? SmashId { get; set; } + + public DateTime Date { get; set; } + + public List Tournaments { get; set; } + + + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Player.cs b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Player.cs new file mode 100644 index 0000000..3d6854b --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Player.cs @@ -0,0 +1,31 @@ +using System; +using System.Security.Cryptography.X509Certificates; + +namespace LaDOSE.Entity +{ + + + public class Player : Context.Entity + { + public Player() + { + } + + public Player(string name, int? challongeId, int? smashId) + { + this.Name = name; + ChallongeId = challongeId; + SmashId = smashId; + } + + + public String SmashName { get; set; } + public String Name { get; set; } + public int? ChallongeId {get;set;} + public int? SmashId {get;set;} + + public Boolean IsChallonge => ChallongeId.HasValue; + + + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Result.cs b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Result.cs new file mode 100644 index 0000000..3429138 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Result.cs @@ -0,0 +1,27 @@ +namespace LaDOSE.Entity +{ + public class Result : Context.Entity + { + + public Result(Player player, int point, int rank, Tournament tournament) + { + Player = player; + Point = point; + Rank = rank; + Tournament = tournament; + + } + + + public Result() + { + } + + public int PlayerId { get; set; } + public Player Player { get; set; } + public int IdTournament { get; set; } + public Tournament Tournament{ get; set; } + public int Point { get; set; } + public int Rank { get; set; } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Tournament.cs b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Tournament.cs new file mode 100644 index 0000000..51cb361 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Entity/TournamentEntities/Tournament.cs @@ -0,0 +1,25 @@ +using System; + +namespace LaDOSE.Entity +{ + public class Tournament : Context.Entity + { + public Tournament() + { + } + + public Tournament(string name, int challongeId, int smashId) + { + Name = name; + ChallongeId = challongeId; + SmashId = smashId; + } + + public String Name { get; set; } + public int ChallongeId {get;set;} + public int SmashId {get;set;} + public int? GameId {get;set;} + public Game Game { get; set; } + + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Interface/ISeasonService.cs b/LaDOSE.Src/LaDOSE.Service/Interface/ISeasonService.cs index 3feaecc..93f2ee8 100644 --- a/LaDOSE.Src/LaDOSE.Service/Interface/ISeasonService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Interface/ISeasonService.cs @@ -2,8 +2,8 @@ namespace LaDOSE.Business.Interface { - public interface ISeasonService : IBaseService - { + //public interface ISeasonService : IBaseService + //{ - } + //} } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs b/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs index 04843a6..3b6635f 100644 --- a/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs @@ -12,5 +12,6 @@ namespace LaDOSE.Business.Interface Task GetTournamentsResult(List ids); Task GetSmashResult(string tournamentSlug); + } } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/SmashProvider.cs b/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/SmashProvider.cs index 89672b2..8188e6e 100644 --- a/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/SmashProvider.cs +++ b/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/SmashProvider.cs @@ -66,26 +66,26 @@ namespace LaDOSE.Business.Provider.SmashProvider id name, state, - videogame { - id, - name, - displayName - } - standings(query: {page:0,perPage:500}){ - nodes{ - id, - player{ - id, - gamerTag, - user { - id, - name, - player { - id - } - } - } - placement + videogame { + id, + name, + displayName + } + standings(query: {page:0,perPage:500}){ + nodes{ + id, + player{ + id, + gamerTag, + user { + id, + name, + player { + id + } + } + } + placement } } diff --git a/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs b/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs index 2e10da9..2155577 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/EventService.cs @@ -20,23 +20,24 @@ namespace LaDOSE.Business.Service this._challongeProvider = challongeProvider; } - public override Event GetById(int id) - { - return _context.Event.Include(e => e.Season).Include(e => e.Games).ThenInclude(e => e.Game) - .FirstOrDefault(e => e.Id == id); - } + //public override Event GetById(int id) + //{ + // re + // //return _context.Event.Include(e => e.Season).Include(e => e.Games).ThenInclude(e => e.Game) + // // .FirstOrDefault(e => e.Id == id); + //} - public override Event Create(Event e) - { - if (e.Id != 0) - { - throw new Exception("Id is invalid"); - } + //public override Event Create(Event e) + //{ + // if (e.Id != 0) + // { + // throw new Exception("Id is invalid"); + // } - var eventAdded = _context.Event.Add(e); - _context.SaveChanges(); - return eventAdded.Entity; - } + // var eventAdded = _context.Event.Add(e); + // _context.SaveChanges(); + // return eventAdded.Entity; + //} } } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Service/GameService.cs b/LaDOSE.Src/LaDOSE.Service/Service/GameService.cs index 9c2300b..9155ed0 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/GameService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/GameService.cs @@ -27,7 +27,7 @@ namespace LaDOSE.Business.Service public override IEnumerable GetAll() { - return _context.Game.Include(e => e.Seasons).ThenInclude(e=>e.Season).ToList(); + return _context.Game.ToList(); } public int GetNextFreeOrder() diff --git a/LaDOSE.Src/LaDOSE.Service/Service/SeasonService.cs b/LaDOSE.Src/LaDOSE.Service/Service/SeasonService.cs deleted file mode 100644 index ca8307f..0000000 --- a/LaDOSE.Src/LaDOSE.Service/Service/SeasonService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using LaDOSE.Business.Interface; -using LaDOSE.Entity; -using LaDOSE.Entity.Context; - -namespace LaDOSE.Business.Service -{ - public class SeasonService : BaseService, ISeasonService - { - public SeasonService(LaDOSEDbContext context) : base(context) - { - } - } -} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs b/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs index f61fa97..f502b32 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs @@ -11,6 +11,7 @@ using LaDOSE.Entity.Context; using LaDOSE.Entity.Wordpress; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; +using Result = LaDOSE.Entity.Challonge.Result; namespace LaDOSE.Business.Service { @@ -120,18 +121,18 @@ namespace LaDOSE.Business.Service var Top8 = tournament.Participents.Where(p => p.Rank > 4 && p.Rank < 9).ToList(); var Top16 = tournament.Participents.Where(p => p.Rank > 8 && p.Rank <= 16).ToList(); - result.Results.Add(new Result(first.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.FirstPoint,first.Rank??0)); + result.Results.Add(new Result(first.Name, tournament.Game?.Id??0, tournament.ChallongeId, tournament.Url, currentRule.FirstPoint,first.Rank??0)); lesSacs.Remove(first); - result.Results.Add(new Result(second.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.SecondPoint, second.Rank ?? 0)); + result.Results.Add(new Result(second.Name, tournament.Game?.Id ?? 0, tournament.ChallongeId, tournament.Url, currentRule.SecondPoint, second.Rank ?? 0)); lesSacs.Remove(second); thirdFourth.ForEach(r => - result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, + result.Results.Add(new Result(r.Name, tournament.Game?.Id ?? 0, tournament.ChallongeId, tournament.Url, currentRule.ThirdFourthPoint, r.Rank ?? 0))); thirdFourth.ForEach(p => lesSacs.Remove(p)); if (currentRule.Top8Point != 0) { Top8.ForEach(r => - result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.Top8Point, r.Rank ?? 0))); + result.Results.Add(new Result(r.Name, tournament.Game?.Id ?? 0, tournament.ChallongeId, tournament.Url, currentRule.Top8Point, r.Rank ?? 0))); Top8.ForEach(p => lesSacs.Remove(p)); } @@ -139,17 +140,21 @@ namespace LaDOSE.Business.Service { Top16.ForEach(r => result.Results.Add( - new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.Top16Point, r.Rank ?? 0))); + new Result(r.Name, tournament.Game?.Id ?? 0, tournament.ChallongeId, tournament.Url, currentRule.Top16Point, r.Rank ?? 0))); Top16.ForEach(p => lesSacs.Remove(p)); } lesSacs.ForEach(r => - result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, + result.Results.Add(new Result(r.Name, tournament.Game?.Id ?? 0, tournament.ChallongeId, tournament.Url, currentRule.Participation, r.Rank ?? 0))); } - - result.Games = tournaments.Select(e => e.Game).Distinct((game, game1) => game.Name == game1.Name).ToList(); - + + result.Games = tournaments.Select(e => e.Game).Distinct((game, game1) => game.Name == game1.Name).Where(e=>e!=null).ToList(); + if (result.Games == null) + { + result.Games = new List(); + } + result.Games.Add(new Game() {Id = 0, Order = 9999,Name = "UNKNOW"}); return result; } @@ -236,6 +241,8 @@ namespace LaDOSE.Business.Service return await Task.FromResult(result); } + + /// /// Check if the tournament exist in database otherwise call Challonge. /// @@ -271,6 +278,10 @@ namespace LaDOSE.Business.Service return tournaments; } + public Task GetSmashTop(string tournamentSlug, string eventId,int playerCount) + { + throw new NotImplementedException(); + } private bool TournamentExist(int idTournament) { return this._context.ChallongeTournament.Any(e => e.ChallongeId == idTournament);