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))); }
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(); }
public ActionResult GetLocationLevelTree(int id) { SearchModelBase model = new SearchModelBase { Locations = _locationService.GetAllCities(id) }; return(PartialView("_LocationsTreeView", model)); }
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)); }
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); } }
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)); }
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()); }
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); }