public IPAddress ClearFails()
        {
            try
            {
                IPAddress addr = FindIPAddressRecord();

                if (addr != null)
                {
                    var db = IPAddressDbContext.getInstance().db;

                    IPAddress _addr = UpsertIPAddress();

                    db.Entry(_addr).State = EntityState.Modified;
                    _addr.Failcount       = 0;
                    db.SaveChanges();

                    addr = _addr;
                }

                return(addr);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        // GET: User

        public IPAddress FindIPAddressRecord()
        {
            var       db        = IPAddressDbContext.getInstance().getItemDb();
            var       ipaddress = GetIPAddress();
            IPAddress addr      = null;

            if (ipaddress != null)
            {
                addr = db.AsNoTracking().Where(a => a.Address == ipaddress).FirstOrDefault();
            }
            return(addr);
        }
        public IPAddress RegisterIPAddressFailLoginRetries()
        {
            var db = IPAddressDbContext.getInstance().db;

            IPAddress addr = UpsertIPAddress();

            // modify + 1 retry count

            db.Entry(addr).State = EntityState.Modified;
            addr.Failcount      += 1;
            db.SaveChanges();

            return(addr);
        }
        public IPAddress CreateNewIPAddressRecord()
        {
            var db        = IPAddressDbContext.getInstance().getItemDb();
            var ipaddress = GetIPAddress();

            var newAddr = new IPAddress();

            newAddr.Address   = ipaddress;
            newAddr.Failcount = 0;
            var id = db.Add(newAddr);

            IPAddressDbContext.getInstance().db.SaveChanges();
            return(newAddr);
        }