public bool FillReferalToDB(string ip, string agent, string deviceModel, string referalCode)
        {
            ReferalCodeTable referal = new ReferalCodeTable();

            referal.IPAddress   = ip;
            referal.UserAgent   = agent;
            referal.DeviceModel = deviceModel;
            referal.IsUsed      = false;
            referal.ReferalCode = referalCode;
            entities.ReferalCodeTables.Add(referal);
            return(entities.SaveChanges() > 0);
        }
        public string FetchReferal(string ipaddress)
        {
            var data = entities.ReferalCodeTables.SingleOrDefault(x => x.IPAddress.Equals(ipaddress));

            if (data != null)
            {
                ReferalCodeTable referalCode = new ReferalCodeTable();
                referalCode.IsUsed = true;
                entities.SaveChanges();
                var referal = data.ReferalCode;
                return(referal);
            }
            return(null);
        }