Commit Debut de rework

This commit is contained in:
2022-03-19 22:54:55 +01:00
parent aebc60d17f
commit ab02d292da
24 changed files with 234 additions and 212 deletions

View File

@@ -2,8 +2,8 @@
namespace LaDOSE.Business.Interface
{
public interface ISeasonService : IBaseService<Season>
{
//public interface ISeasonService : IBaseService<Season>
//{
}
//}
}

View File

@@ -12,5 +12,6 @@ namespace LaDOSE.Business.Interface
Task<TournamentsResult> GetTournamentsResult(List<int> ids);
Task<TournamentsResult> GetSmashResult(string tournamentSlug);
}
}

View File

@@ -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
}
}

View File

@@ -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;
//}
}
}

View File

@@ -27,7 +27,7 @@ namespace LaDOSE.Business.Service
public override IEnumerable<Game> GetAll()
{
return _context.Game.Include(e => e.Seasons).ThenInclude(e=>e.Season).ToList();
return _context.Game.ToList();
}
public int GetNextFreeOrder()

View File

@@ -1,13 +0,0 @@
using LaDOSE.Business.Interface;
using LaDOSE.Entity;
using LaDOSE.Entity.Context;
namespace LaDOSE.Business.Service
{
public class SeasonService : BaseService<Season>, ISeasonService
{
public SeasonService(LaDOSEDbContext context) : base(context)
{
}
}
}

View File

@@ -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<Game>();
}
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);
}
/// <summary>
/// Check if the tournament exist in database otherwise call Challonge.
/// </summary>
@@ -271,6 +278,10 @@ namespace LaDOSE.Business.Service
return tournaments;
}
public Task<object> GetSmashTop(string tournamentSlug, string eventId,int playerCount)
{
throw new NotImplementedException();
}
private bool TournamentExist(int idTournament)
{
return this._context.ChallongeTournament.Any(e => e.ChallongeId == idTournament);