Esempio n. 1
0
        private static string GetValue(PropertyInfo propertyInfo, SearchModelBase searchModel)
        {
            var value = propertyInfo.GetValue(searchModel, null);

            if (value == null)
            {
                return(null);
            }

            if (value is DateTime)
            {
                return(((DateTime)value).ToString(Constants.SeekitDefaultDateTimeFormat));
            }

            if (value is string)
            {
                return(HttpUtility.HtmlEncode(value));
            }

            if (typeof(IEnumerable).IsAssignableFrom(propertyInfo.PropertyType))
            {
                return(HttpUtility.HtmlEncode(JsonConvert.SerializeObject(value)));
            }

            return(HttpUtility.HtmlEncode(JsonConvert.SerializeObject(value)));
        }
Esempio n. 2
0
        public string GenerateMetaTags(SearchModelBase searchModel)
        {
            var sb = new StringBuilder();
            var searchModelType = searchModel.GetType();
            var properties = searchModelType.GetProperties();

            foreach (var propertyInfo in properties) {

                if(Ignore(propertyInfo)) continue;

                var value = GetValue(propertyInfo, searchModel);
                if (value == null)
                    value = "null";

                var name = GetName(propertyInfo);

                if(name.ToLower() == Constants.SeekitTypedModelsName.ToLower())
                    throw new DuplicateNameException("The propetyname: " +Constants.SeekitTypedModelsName +" is used internaly by seekit and may not be used as a SearchModel property name");

                var metaTag = string.Format(Constants.SeekitMetaTagFormat,
                    name,
                    value,
                    GetType(propertyInfo),
                    IsFacet(propertyInfo));

                sb.AppendLine(metaTag);
            }

            sb.AppendLine(SearchModelTypes(searchModel));

            return sb.ToString();
        }
Esempio n. 3
0
        public ActionResult GetLocationLevelTree(int id)
        {
            SearchModelBase model = new SearchModelBase {
                Locations = _locationService.GetAllCities(id)
            };

            return(PartialView("_LocationsTreeView", model));
        }
Esempio n. 4
0
        private string SearchModelTypes(SearchModelBase searchModel)
        {
            var currentType = searchModel.GetType();
            var typesList   = new List <string>();

            while (currentType != null && currentType.FullName != "System.Object")
            {
                typesList.Add(currentType.JsonNetFormat());
                currentType = currentType.BaseType;
            }
            return(string.Format(Constants.SeekitMetaTagFormat,
                                 Constants.SeekitTypedModelsName,
                                 HttpUtility.HtmlEncode(JsonConvert.SerializeObject(typesList)),
                                 "IEnumerable",
                                 false));
        }
Esempio n. 5
0
 public void FillLocInfo(SearchModelBase model)
 {
     model.Countries      = _locationService.GetCountries();
     model.Locationlevel1 = new List <SelectListItem>();
     foreach (var country in model.Countries)
     {
         var states = _locationService.GetLocationLevel1(country.Id)
                      .Select(c => new SelectListItem
         {
             Value = c.Id.ToString(),
             Text  = $"({country.Name.Substring(0, 2).ToUpper()}) - {c.Name}"
         })
                      .ToList();
         model.Locationlevel1.AddRange(states);
     }
 }
Esempio n. 6
0
        private static string GetValue(PropertyInfo propertyInfo, SearchModelBase searchModel)
        {
            var value = propertyInfo.GetValue(searchModel, null);

            if(value == null)
                return null;

            if(value is DateTime) {
                return ((DateTime) value).ToString(Constants.SeekitDefaultDateTimeFormat);
            }

            if(value is string) {
                return HttpUtility.HtmlEncode(value);
            }

            if (typeof(IEnumerable).IsAssignableFrom(propertyInfo.PropertyType)){
                return HttpUtility.HtmlEncode(JsonConvert.SerializeObject(value));
            }

            return HttpUtility.HtmlEncode(JsonConvert.SerializeObject(value));
        }
Esempio n. 7
0
        public string GenerateMetaTags(SearchModelBase searchModel)
        {
            var sb = new StringBuilder();
            var searchModelType = searchModel.GetType();
            var properties      = searchModelType.GetProperties();

            foreach (var propertyInfo in properties)
            {
                if (Ignore(propertyInfo))
                {
                    continue;
                }

                var value = GetValue(propertyInfo, searchModel);
                if (value == null)
                {
                    value = "null";
                }

                var name = GetName(propertyInfo);

                if (name.ToLower() == Constants.SeekitTypedModelsName.ToLower())
                {
                    throw new DuplicateNameException("The propetyname: " + Constants.SeekitTypedModelsName + " is used internaly by seekit and may not be used as a SearchModel property name");
                }

                var metaTag = string.Format(Constants.SeekitMetaTagFormat,
                                            name,
                                            value,
                                            GetType(propertyInfo),
                                            IsFacet(propertyInfo));

                sb.AppendLine(metaTag);
            }

            sb.AppendLine(SearchModelTypes(searchModel));

            return(sb.ToString());
        }
Esempio n. 8
0
 private string SearchModelTypes(SearchModelBase searchModel)
 {
     var currentType = searchModel.GetType();
     var typesList = new List<string>();
     while (currentType != null && currentType.FullName != "System.Object") {
         typesList.Add(currentType.JsonNetFormat());
         currentType = currentType.BaseType;
     }
     return string.Format(Constants.SeekitMetaTagFormat,
                 Constants.SeekitTypedModelsName,
                 HttpUtility.HtmlEncode(JsonConvert.SerializeObject(typesList)),
                 "IEnumerable",
                 false);
 }