private List <SearchFilterModel> MapSearchFilter(NavigationContainer navigation) { List <SearchFilterModel> result = new List <SearchFilterModel>(); if (navigation != null && navigation.NavigationItems != null) { foreach (var navItem in navigation.NavigationItems) { //如果没有筛选项或数量过少就丢弃 if (navItem.SubNavigationItems == null || navItem.SubNavigationItems.Count == 0) { continue; } SearchFilterModel filterModel = new SearchFilterModel(); filterModel.ID = (int)navItem.ItemType; filterModel.Name = navItem.Name; foreach (var subItem in navItem.SubNavigationItems) { SearchFilterItemModel itemModel = new SearchFilterItemModel(); itemModel.EnId = subItem.Value; itemModel.Name = subItem.Name; itemModel.ProductCount = subItem.NumberOfItem; filterModel.Items.Add(itemModel); } result.Add(filterModel); } } return(result); }
public ActionResult SearchListing(SearchFilterModel searchFilterModel) { var AllListing = new ProviderListingModel().GetAllListing().Where(g => g.IsApproved == (int)ListingStatus.Accepted).ToList(); ViewBag.AllListing = AllListing; ViewBag.CategoryList = new ProviderListingModel().AllCategory(); ViewBag.Categorylists = new SelectList(new ProviderListingModel().AllCategory(), "Id", "CategoryName", "Select the Category"); if (searchFilterModel.Location != null) { var newAllListing = new List <ProviderListingModel>(); foreach (var list in AllListing) { foreach (var Servicearea in list.ServiceAreas) { int num; bool isNum = int.TryParse(searchFilterModel.Location, out num); if (isNum) { int CheckZipCode = Convert.ToInt32(searchFilterModel.Location); var distance = getDistance(CheckZipCode, (int)Servicearea.ZipCode); if (distance <= Convert.ToDecimal(Servicearea.ServiceRadius)) { newAllListing.Add(list); break; } } else { if (Servicearea.City.ToLower() == searchFilterModel.Location.ToLower()) { newAllListing.Add(list); break; } } } } if (searchFilterModel.selectedCategory != null) { newAllListing = newAllListing.Where(f => searchFilterModel.selectedCategory.Contains(f.ProviderCategory1.Id)).ToList(); ViewBag.selectedCat = searchFilterModel.selectedCategory; } if (searchFilterModel.SortBy != null) { newAllListing = newAllListing.Where(f => f.ProviderCategory1.Id == searchFilterModel.SortBy).ToList(); } return(View(newAllListing.OrderByDescending(d => d.ProviderListingId).ToPagedList(searchFilterModel.page ?? 1, 10))); } if (searchFilterModel.selectedCategory != null) { AllListing = AllListing.Where(f => searchFilterModel.selectedCategory.Contains(f.ProviderCategory1.Id)).ToList(); ViewBag.selectedCat = searchFilterModel.selectedCategory; } if (searchFilterModel.SortBy != null) { AllListing = AllListing.Where(f => f.ProviderCategory1.Id == searchFilterModel.SortBy).ToList(); } return(View(AllListing.OrderByDescending(d => d.ProviderListingId).ToPagedList(searchFilterModel.page ?? 1, 10))); }
private string GetComparison(SearchFilterModel searchFilterModel) { switch (searchFilterModel.Comprison) { case Comparisons.Equal: return(Constants.ODataEqual); case Comparisons.NotEqual: return(Constants.ODataNotEqual); case Comparisons.GreaterThan: return(Constants.ODataGreaterThan); case Comparisons.GreaterEqualThan: return(Constants.ODataGreaterEqualThan); case Comparisons.LessThan: return(Constants.ODataLessThan); case Comparisons.LessEqualThan: return(Constants.ODataLessEqualThan); default: throw new NotImplementedException($"Comparison {searchFilterModel.Comprison} is not implemented or is invalid."); } }
public IQueryable <T> GetMasterTagList <T>(SearchFilterModel searchFilterModel, TokenModel tokenModel) where T : class, new() { SqlParameter[] parameters = { new SqlParameter("@SearchText", searchFilterModel.SearchText), new SqlParameter("@OrganizationId", tokenModel.OrganizationID), new SqlParameter("@PageNumber", searchFilterModel.pageNumber), new SqlParameter("@PageSize", searchFilterModel.pageSize), new SqlParameter("@SortColumn", searchFilterModel.sortColumn), new SqlParameter("@SortOrder", searchFilterModel.sortOrder) }; return(_context.ExecStoredProcedureListWithOutput <T>(SQLObjects.MTR_GetMasterTags, parameters.Length, parameters).AsQueryable()); }
public string GetFilter(SearchFilterModel searchFilterModel, Member member) { string value; if (!TryGetDateTimeValueString(searchFilterModel, member, out value)) { value = searchFilterModel.Value; } return($"{member.Name} {GetComparison(searchFilterModel)} {value}"); }
private bool TryGetDateTimeValueString(SearchFilterModel searchFilterModel, Member member, out string dateTimeString) { dateTimeString = null; if (member.Type == typeof(DateTime)) { dateTimeString = DateTime.Parse(searchFilterModel.Value).ToString("s") + "Z"; } else if (member.Type == typeof(DateTimeOffset)) { dateTimeString = DateTimeOffset.Parse(searchFilterModel.Value).ToString("s") + "Z"; } return(dateTimeString != null); }
public virtual PartialViewResult Search(SearchFilterModel model) { var searchableTypeIds = model.Types.Count > 0 ? model.Types : GetSearchableTypes().Select(t => t.ToInt()); var searchResult = _elasticIndex.Search(new SearchTextQuery { Text = model.Query, Take = ResultsPerPage * model.Page, SearchableTypeIds = searchableTypeIds, OnlyPinned = model.OnlyPinned, ApplyHighlights = true }); var resultModel = GetSearchResultsOverviewModel(searchResult); resultModel.Query = model.Query; return(PartialView(SearchResultViewPath, resultModel)); }
public override PartialViewResult Search(SearchFilterModel model) { var searchableTypeIds = model.Types.Count > 0 ? model.Types : GetSearchableTypes().Select(t => t.ToInt()); var searchResult = _elasticIndex.Search(new SearchTextQuery { Text = model.Query, OnlyPinned = model.OnlyPinned, Take = ResultsPerPage * model.Page, SearchableTypeIds = searchableTypeIds, ApplyHighlights = true }); var resultModel = GetUintraSearchResultsOverviewModel(searchResult); var decodedQuery = Encoding.UTF8.GetString(model.Query.Select(c => (byte)c).ToArray()); resultModel.Query = decodedQuery; return(PartialView(SearchResultViewPath, resultModel)); }
public string GetFilter(SearchFilterModel searchFilterModel, Member member) { return($"{member.Name} {GetComparison(searchFilterModel)} {searchFilterModel.Value}"); }
public GetAuthorizationByIdModel GetAutorizationById(SearchFilterModel searchFilterModel, TokenModel tokenModel) { SqlParameter[] parameters = { new SqlParameter("@AuthorizationId", searchFilterModel.AuthorizationId) , new SqlParameter("@OrganizationId", tokenModel.OrganizationID) }; return(_context.ExecStoredProcedureForGetAutorizationById(SQLObjects.MTR_GetAuthorizationById.ToString(), parameters.Length, parameters)); }
public async Task <IActionResult> Search([FromBody] SearchFilterModel filter) { var result = await _mediator.Send(new SearchCommand(filter)); return(Ok(result)); }
public SearchCommand(SearchFilterModel filter) { Filter = filter; }