public async Task <PlayerInvite> AnswerLaterInvite(int inviteID) { PlayerInvite invite = _context.PlayerInvites.Where(x => x.Id == inviteID).FirstOrDefault(); if (invite != null) { invite.IsAnswerLater = true; await _context.SaveChangesAsync(); return(invite); } return(new PlayerInvite()); }
public async Task <PlayerInvite> DeclineInvite(int inviteID) { PlayerInvite invite = _context.PlayerInvites.Where(x => x.Id == inviteID && (x.IsDeleted == false || x.IsDeleted == null)).FirstOrDefault(); if (invite != null) { invite.IsDeclined = true; await _context.SaveChangesAsync(); return(invite); } return(new PlayerInvite()); }
public async Task <PlayerInvite> AcceptInvite(int inviteID, int characterID) { PlayerInvite invite = _context.PlayerInvites.Where(x => x.Id == inviteID && (x.IsDeleted == false || x.IsDeleted == null)).FirstOrDefault(); if (invite != null) { invite.IsAccepted = true; invite.PlayerCharacterID = characterID; //add player Controls PlayerControl control = new PlayerControl() { PlayerCharacterID = characterID, CampaignID = invite.PlayerCampaignID, PauseAbilityAdd = false, PauseAbilityCreate = false, PauseBuffAndEffectAdd = false, PauseBuffAndEffectCreate = false, PauseGame = false, PauseItemAdd = false, PauseItemCreate = false, PauseSpellAdd = false, PauseSpellCreate = false, }; if (_context.PlayerControls.Where(x => x.CampaignID == invite.PlayerCampaignID).Any()) { PlayerControl OldControl = _context.PlayerControls.Where(x => x.CampaignID == invite.PlayerCampaignID).FirstOrDefault(); control = new PlayerControl() { PlayerCharacterID = characterID, CampaignID = invite.PlayerCampaignID, PauseAbilityAdd = OldControl.PauseAbilityAdd, PauseAbilityCreate = OldControl.PauseAbilityCreate, PauseBuffAndEffectAdd = OldControl.PauseBuffAndEffectAdd, PauseBuffAndEffectCreate = OldControl.PauseBuffAndEffectCreate, PauseGame = OldControl.PauseGame, PauseItemAdd = OldControl.PauseItemAdd, PauseItemCreate = OldControl.PauseItemCreate, PauseSpellAdd = OldControl.PauseSpellAdd, PauseSpellCreate = OldControl.PauseSpellCreate, }; } await _context.PlayerControls.AddAsync(control); await _context.SaveChangesAsync(); return(invite); } return(new PlayerInvite()); }
public async Task <PlayerInvite> CreatePlayerInvite(PlayerInviteEmail model, string PlayerUserId, bool IsInviteSentUsingUserName) { PlayerInvite invite = new PlayerInvite(); invite.IsAccepted = false; invite.PlayerCampaignID = model.CampaignId; invite.PlayerCharacterID = null; invite.PlayerUserID = PlayerUserId; invite.SendByUserID = model.SendByUserId; invite.PlayerEmail = model.UserName; invite.IsSendToUserName = IsInviteSentUsingUserName; invite.SendOn = DateTime.Now; await _context.PlayerInvites.AddAsync(invite); await _context.SaveChangesAsync(); return(invite); }