Add new agnostic challonge provider

This commit is contained in:
2022-03-20 19:36:15 +01:00
parent 92b6d3e568
commit ee48b7d75c
17 changed files with 561 additions and 314 deletions

View File

@@ -2,6 +2,7 @@
using LaDOSE.Business.Interface;
using LaDOSE.Business.Provider.SmashProvider;
using LaDOSE.Entity;
using LaDOSE.Entity.Challonge;
using LaDOSE.Entity.Context;
using Microsoft.EntityFrameworkCore.Internal;
@@ -14,7 +15,7 @@ namespace LaDOSE.Business.Service
{
}
public int GetBySmash(ParticipantType participantUser)
public int GetIdBySmash(ParticipantType participantUser)
{
//var p2 = _context.Player.ToList();
@@ -41,5 +42,29 @@ namespace LaDOSE.Business.Service
return p.Id;
}
public int GetIdByName(ChallongeParticipent challongeParticipent)
{
if (string.IsNullOrEmpty(challongeParticipent.Name))
{
challongeParticipent.Name = "UNKNOWPLAYER";
}
var p = _context.Player.FirstOrDefault(e => e.Gamertag == challongeParticipent.Name);
if (p == null)
{
var entity = new Player()
{
Gamertag = challongeParticipent.Name,
Name = challongeParticipent.Name,
ChallongeId = challongeParticipent.ChallongeId,
};
_context.Player.Add(entity);
_context.SaveChanges();
return entity.Id;
}
return p.Id;
}
}
}