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