public static SearchAttributeViewModel GetSearchAttributeViewModel(SearchAttribute searchAttribute) { SearchAttributeViewModel sa = new SearchAttributeViewModel(); sa.id = searchAttribute.id; //names sa.displayName = searchAttribute.displayName; sa.metadataNames.AddRange(searchAttribute.metadataName.Split(',')); //types sa.dataType = SearchAttribute.GetDataTypeAsDisplayString(searchAttribute.dataType); sa.searchType = SearchAttribute.GetSearchTypeAsDisplayString(searchAttribute.searchType); // parameter for index sa.store = searchAttribute.store; sa.multiValue = searchAttribute.multiValue; sa.analysed = searchAttribute.analysed; sa.norm = searchAttribute.norm; sa.boost = searchAttribute.boost; // resultview sa.headerItem = searchAttribute.headerItem; sa.defaultHeaderItem = searchAttribute.defaultHeaderItem; // properties sa.direction = SearchAttribute.GetDirectionAsString(searchAttribute.direction); sa.uiComponent = SearchAttribute.GetUIComponentAsString(searchAttribute.uiComponent); sa.aggregationType = SearchAttribute.GetAggregationTypeAsString(searchAttribute.aggregationType); //sa.dateFormat = searchAttribute.dateFormat; return(sa); }
public static SearchAttribute GetSearchAttribute(SearchAttributeViewModel searchAttributeViewModel) { SearchAttribute sa = new SearchAttribute(); //names sa.displayName = searchAttributeViewModel.displayName; sa.sourceName = Regex.Replace(searchAttributeViewModel.displayName, "[^0-9a-zA-Z]+", ""); sa.metadataName = String.Join(",", searchAttributeViewModel.metadataNames.Where(x => !string.IsNullOrEmpty(x)).ToArray()); //types sa.dataType = SearchAttribute.GetDataType(searchAttributeViewModel.dataType); sa.searchType = SearchAttribute.GetSearchType(searchAttributeViewModel.searchType); // parameter for index sa.store = searchAttributeViewModel.store; sa.multiValue = searchAttributeViewModel.multiValue; sa.analysed = searchAttributeViewModel.analysed; sa.norm = searchAttributeViewModel.norm; sa.boost = searchAttributeViewModel.boost; // resultview sa.headerItem = searchAttributeViewModel.headerItem; sa.defaultHeaderItem = searchAttributeViewModel.defaultHeaderItem; // properties sa.direction = SearchAttribute.GetDirection(searchAttributeViewModel.direction); sa.uiComponent = SearchAttribute.GetUIComponent(searchAttributeViewModel.uiComponent); sa.aggregationType = SearchAttribute.GetAggregationType(searchAttributeViewModel.aggregationType); //sa.dateFormat = searchAttributeViewModel.dateFormat; return(sa); }