public void BanPlayer(PlayerBanData playerBanData) { using (var db = frsDatabase.Create()) { ban ban = new ban { BannedDateTime = DateTime.Now, PlayerName = playerBanData.PlayerName, Admin = playerBanData.Admin, Reason = playerBanData.Reason, IsPermanentBan = playerBanData.IsPermanentBan, BannedUntil = playerBanData.BannedUntil, IsCurrentlyBanned = true, IpAddresses = String.Join(",", playerBanData.IpAddresses) }; db.ban.Add(ban); db.SaveChanges(); } }
public bool UnbanPlayer(string playerName, string adminName) { using (var db = frsDatabase.Create()) { ban bannedPlayer = db.ban.FirstOrDefault( x => x.PlayerName.Equals(playerName, StringComparison.InvariantCultureIgnoreCase) && x.IsCurrentlyBanned); if (bannedPlayer == null) { return(false); } bannedPlayer.IsCurrentlyBanned = false; bannedPlayer.IsPermanentBan = false; bannedPlayer.ModifiedByAdmin = adminName; bannedPlayer.ModifiedDateTime = DateTime.Now; db.SaveChanges(); return(true); } }