public bool?TryAccessGranted() { var ipList = _repository.ReadAll().Select(x => x.IpNetwork).ToList(); if (ipList.Any() == false) { return(null); } var requestIp = _context.HttpContext.Connection.RemoteIpAddress.MapToIPv4(); foreach (var cidr in ipList) { if (_validatorService.IsInRange(requestIp, cidr)) { return(true); } } return(false); }
public async Task <IEnumerable <IpNetworkModel> > GetAll() { return(await Task.FromResult(_repository.ReadAll().ToModels()).ConfigureAwait(false)); }