Ejemplo n.º 1
0
        public bool IsOKWithGeolocation(Member user)
        {
            if (!IsGeolocated)
            {
                return(true);
            }

            if (!String.IsNullOrWhiteSpace(GeolocatedCC) && !GeolocatedCC.Contains(user.CountryCode.Trim()))
            {
                return(false);
            }

            if (GeolocatedAgeMin > 0 && user.Age < GeolocatedAgeMin)
            {
                return(false);
            }

            if (GeolocatedAgeMax > 0 && user.Age > GeolocatedAgeMax)
            {
                return(false);
            }

            if (GeolocatedGender != Gender.Null && GeolocatedGender != user.Gender)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public List <string> GetGeolocatedCountries()
        {
            List <string> countriesList = new List <string>();
            var           str           = GeolocatedCC.TrimEnd(',');
            var           charsToRemove = new string[] { "[", "]", "\"", "\"" };

            foreach (var c in charsToRemove)
            {
                str = str.Replace(c, string.Empty);
            }

            var ccs = str.Split(Delimiter);

            foreach (var cc in ccs)
            {
                countriesList.Add(CountryManager.GetCountryName(cc));
            }

            return(countriesList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks whether the member passes the geolocation requirements or not
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool IsGeolocationMeet(Member user)
        {
            if (IsGeolocated)
            {
                try
                {
                    if (IsGeolocatedByCountry && !GeolocatedCC.Contains(user.CountryCode))
                    {
                        return(false);
                    }

                    if (IsGeolocatedByCity && !GeolocatedCities.Contains(user.City))
                    {
                        return(false);
                    }

                    if (IsGeolocatedByGender && user.Gender != GeolocatedGender)
                    {
                        return(false);
                    }

                    if (GeolocatedAgeMin > 0 && user.Age < GeolocatedAgeMin)
                    {
                        return(false);
                    }

                    if (GeolocatedAgeMax > 0 && user.Age > GeolocatedAgeMax)
                    {
                        return(false);
                    }

                    if (!IsGeolocationProfileMeet(GeolocationProfile, user))
                    {
                        return(false);
                    }
                }
                catch (Exception ex) { ErrorLogger.Log(ex); }
            }

            return(true);
        }
Ejemplo n.º 4
0
        public bool IsGeolocationMet(string countryCode, int?age, Gender gender)
        {
            if (IsGeolocated)
            {
                try
                {
                    if (IsGeolocatedByCountry && !GeolocatedCC.Contains(countryCode))
                    {
                        return(false);
                    }

                    //Geolocation by city is not implemented

                    //if (IsGeolocatedByCity && !GeolocatedCities.Contains(user.City))
                    //    return false;

                    if (IsGeolocatedByGender && gender != GeolocatedGender)
                    {
                        return(false);
                    }

                    if (GeolocatedAgeMin > 0 && (!age.HasValue || age < GeolocatedAgeMin))
                    {
                        return(false);
                    }

                    if (GeolocatedAgeMax > 0 && (!age.HasValue || age > GeolocatedAgeMax))
                    {
                        return(false);
                    }
                }
                catch (Exception ex) { ErrorLogger.Log(ex); }
            }

            return(true);
        }