Ejemplo n.º 1
0
        public ZipIpVerifyResult VerifyZipAndIpAddress(string ip, string zip, string email)
        {
            if (_db.CbrZipVerifieds.Any(z => z.EmailAddress == email && z.ValidZip == zip && z.ValidIpAddress == ip))
            {
                //should default to true
                return(new ZipIpVerifyResult());
            }


            IpInfo        = _xverifyRepository.GetIpVerification(ip);
            ZipLookupInfo = _xverifyRepository.GetZipcodeLookup(zip);

            var _zipIpVerifyResult = new ZipIpVerifyResult();

            if (IpInfo.IsValid && !IpInfo.IsIrreputable && ZipLookupInfo.IsValid)
            {
                if (IpInfo.ipdata.region == ZipLookupInfo.zipdata.state)
                {
                    _db.CbrZipVerifieds.Add(new CbrZipVerified()
                    {
                        EmailAddress   = email,
                        ValidIpAddress = ip,
                        ValidZip       = zip
                    });
                    _db.SaveChanges();
                    //return new ZipIpVerifyResult() { IsValid = true };
                    _zipIpVerifyResult.IsValid = true;
                }
                else
                {
                    _zipIpVerifyResult.NoMatch = true;
                }
            }

            _zipIpVerifyResult.IpIsIrReputable = IpInfo.IsIrreputable;
            _zipIpVerifyResult.ZipCodeInvalid  = !ZipLookupInfo.IsValid;
            _zipIpVerifyResult.IpInvalid       = !IpInfo.IsValid;

            if (!_zipIpVerifyResult.IsValid)
            {
                LogInvalidEntry(ip, zip, email, _zipIpVerifyResult);
            }

            return(_zipIpVerifyResult);
        }
Ejemplo n.º 2
0
 public IHttpActionResult VerifyIP(string ip)
 {
     try
     {
         return(Ok(_xverifyRepository.GetIpVerification(ip)));
     }
     catch (Exception e)
     {
         if (e.InnerException != null)
         {
             return(Ok(e.InnerException.Message));
         }
         return(Ok(e.Message));
     }
 }