public async Task <bool> getIpIsBanned([FromBody] string IpAddress) { DateTime now = DateTime.UtcNow; BannedIp ban = (from b in db.BannedIp where b.IpAddress == IpAddress && b.FromDt <= now && (b.ToDt == null || b.ToDt > now) select b).FirstOrDefault(); return(ban != null ? true : false); }
public async Task <dynamic> banIp([FromBody] BanRequestDTO request) { DateTime now = DateTime.UtcNow; BannedIp newBan = new BannedIp() { IpAddress = request.IpAddress, FromDt = now, ToDt = request.ToDt }; db.BannedIp.Add(newBan); db.SaveChanges(); return(Ok("Ip Banned")); }