From 8fd6c532c5bbcc5083f5c439b03c943f73410fc5 Mon Sep 17 00:00:00 2001 From: Darkstack <1835601+darkstack@users.noreply.github.com> Date: Mon, 1 Aug 2022 20:37:06 +0200 Subject: [PATCH] Users hand registered --- .../Provider/SmashProvider/Tournament.cs | 2 +- LaDOSE.Src/LaDOSE.Service/Service/PlayerService.cs | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/Tournament.cs b/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/Tournament.cs index a438799..4881687 100644 --- a/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/Tournament.cs +++ b/LaDOSE.Src/LaDOSE.Service/Provider/SmashProvider/Tournament.cs @@ -61,7 +61,7 @@ namespace LaDOSE.Business.Provider.SmashProvider { public int id { get; set; } public string gamerTag { get; set; } - public UserType user { get; set; } + public UserType? user { get; set; } } public class UserType { diff --git a/LaDOSE.Src/LaDOSE.Service/Service/PlayerService.cs b/LaDOSE.Src/LaDOSE.Service/Service/PlayerService.cs index 8c84a0a..1267233 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/PlayerService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/PlayerService.cs @@ -17,9 +17,13 @@ namespace LaDOSE.Business.Service public int GetIdBySmash(ParticipantType participantUser) { + Player p = null; //var p2 = _context.Player.ToList(); - - var p = _context.Player.FirstOrDefault(e => e.SmashId == participantUser.user.id); + if (participantUser.user != null) + { + p = _context.Player.FirstOrDefault(e => e.SmashId == participantUser.user.id); + } + if (p == null) { @@ -28,15 +32,15 @@ namespace LaDOSE.Business.Service { if (p.SmashId == null) { - p.SmashId = participantUser.user.id; + p.SmashId = participantUser.user?.id; } return p.Id; } var entity = new Player() { Gamertag = participantUser.gamerTag, - Name = string.IsNullOrEmpty(participantUser.user.name)? participantUser.gamerTag : participantUser.user.name, - SmashId = participantUser.user.id, + Name = string.IsNullOrEmpty(participantUser.user?.name)? participantUser.gamerTag : participantUser.user.name, + SmashId = participantUser.user?.id, }; _context.Player.Add(entity); _context.SaveChanges();