Example #1
0
        public static IPViewModel GetIpCountry(int IntIP)
        {
            if (IPCountryStore != null)
            {
                var item = GetIPCountryRecord(IntIP);

                if (item != null && item.CountryId != 0)
                {
                    var countrycode = CountryCode.FromShort(item.CountryId);

                    var countryname = CountryCode.GetCountryName(countrycode);

                    if (!string.IsNullOrWhiteSpace(countryname))
                    {
                        IPViewModel model = new IPViewModel();
                        model.Ip = Lib.Helper.IPHelper.FromInt(IntIP);

                        model.CountryCode = countrycode;
                        model.CountryName = countryname;

                        return(model);
                    }
                }
            }

            return(null);
        }
Example #2
0
        public static IPViewModel GetIpCity(int IntIP)
        {
            if (IpCityStore != null)
            {
                var item = GetIpCityRecord(IntIP);

                if (item != null && item.CityId != 0)
                {
                    var cityinfo = CityStore.get(item.CityId);

                    if (cityinfo != null)
                    {
                        var stateinfo = StateStore.get(cityinfo.State);

                        IPViewModel model = new IPViewModel();
                        model.Ip = Lib.Helper.IPHelper.FromInt(IntIP);

                        model.City = cityinfo.CityName;

                        if (stateinfo != null)
                        {
                            model.State       = stateinfo.StateName;
                            model.CountryCode = CountryCode.FromShort(stateinfo.Country);
                            model.CountryName = CountryCode.GetCountryName(stateinfo.Country);
                        }

                        return(model);
                    }
                }
            }

            return(GetIpCountry(IntIP));
        }