private static NearbySearchResult GetNearbySearchResult(SearchVm searchVm) { NearbySearchResult result = null; if (searchVm.PageType.ToSearchType() != SearchType.ProductsAndServices) { CommunitiesSearchVm communitiesSearchVm = searchVm as CommunitiesSearchVm; if (communitiesSearchVm != null) { CommunityNearbySearchModel searchModel = communitiesSearchVm.ToCommunityNearbySearchModel(); searchModel = SearchBc.Instance.SearchNearbyCommunities(searchModel); result = searchModel.Result; } } else { ServiceProvidersSearchVm serviceProvidersSearchVm = searchVm as ServiceProvidersSearchVm; if (serviceProvidersSearchVm != null) { NearbySearchModel searchModel2 = serviceProvidersSearchVm.ToNearbySearchModel(); searchModel2 = SearchBc.Instance.SearchNearbyServiceProviders(searchModel2); result = searchModel2.Result; } } return(result); }
public static CommunitiesSearchVm GetCommunitiesSearchVm(CommunitiesSearchVm searchVm) { if (!ValidatePageNumber(searchVm.PageNumber)) { return(null); } searchVm.ValidationResult = GetLookupLocationValidationVm(searchVm.SearchBar); if (!searchVm.ValidationResult.IsValid) { return(searchVm); } searchVm.Criteria = searchVm.ValidationResult.Criteria; searchVm.SearchBar = GetSearchBarVm(searchVm); CommunitySearchModel searchModel = searchVm.ToCommunitySearchModel(); FeaturedCommunitySearchModel searchModel2 = searchVm.ToFeaturedCommunitySearchModel(); searchModel = SearchBc.Instance.SearchCommunities(searchModel); searchModel2 = SearchBc.Instance.SearchFeaturedCommunities(searchModel2); searchVm.PageSize = searchModel.PageSize; searchVm.TotalCount = searchModel.Result.TotalCount; searchVm.Paging = searchVm.MapToPagingVm(); searchVm.Refine = searchVm.MapToCommunityRefineVm(); searchVm.Result = searchModel.Result.Results.MapToCommunityBlockVmList(searchVm.Criteria.SearchType()); searchVm.FeaturedCommunities = searchModel2.Result.MapToCommunityShortVmList(searchVm.Criteria.SearchType()); PopulateFeaturedServices(searchVm); searchVm.Breadcrumbs = GetBreadcrumbs(searchVm); searchVm.LeadForm = GetLeadFormVm(searchVm); searchVm.Seo = SeoHelper.GetSeo(searchVm); return(searchVm); }
public static string PagingUrl(CommunitiesSearchVm model, int pageNumber) { return(model.PageType.FluentUrl().State(model.Criteria.StateCode()).Zip(model.Criteria.Zip()) .City(model.Criteria.City()) .Refined(RefinedParameters(model)) .WithPaging(pageNumber) .Url()); }
public static LeadFormVm GetLeadFormVm(CommunitiesSearchVm vm) { LeadFormVm leadFormVm = GetLeadFormVm(); leadFormVm.Message = vm.GetLeadFormMessage(); leadFormVm.Brand = vm.PageType.ToSearchType().MapToBrandType(); leadFormVm.Inquiry = InquiryType.Community; return(leadFormVm); }
internal static FeaturedCommunitySearchModel ToFeaturedCommunitySearchModel(this CommunitiesSearchVm searchVm) { return(new FeaturedCommunitySearchModel() { Criteria = searchVm.Criteria.ToSearchCriteria(), MaxCount = SearchExtentions.Config.FeaturedCommunitiesMaxCount, ListingType = searchVm.Criteria.SearchType().ToListingType() }); }
internal static CommunityNearbySearchModel ToCommunityNearbySearchModel(this CommunitiesSearchVm searchVm) { return(new CommunityNearbySearchModel() { Criteria = searchVm.Criteria.ToSearchCriteria(), ListingType = searchVm.Criteria.SearchType().ToListingType(), MaxCount = SearchExtentions.Config.NearbyCitiesMaxCount }); }
internal static PagingVm MapToPagingVm(this CommunitiesSearchVm searchVm) { PagingVm pagingVm = MapToCommonPagingVm(searchVm); foreach (PageLinkVm page in pagingVm.Pages) { page.Href = MslcUrlBuilder.PagingUrl(searchVm, page.PageNumber); } return(pagingVm); }
protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) { CommunitiesSearchVm communitiesSearchVm = bindingContext.Model as CommunitiesSearchVm; base.BindProperty(controllerContext, bindingContext, propertyDescriptor); if (communitiesSearchVm != null) { BindListingsSearchModel(communitiesSearchVm, controllerContext, propertyDescriptor); } }
internal static CommunitySearchModel ToCommunitySearchModel(this CommunitiesSearchVm searchVm) { long?nullable; long?nullable1; long?nullable2; CommunitySearchModel communitySearchModel = new CommunitySearchModel() { Criteria = searchVm.Criteria.ToSearchCriteria(), PageNumber = searchVm.PageNumber, PageSize = SearchExtentions.Config.DefaultPageSize, SortType = searchVm.SortType, ListingType = searchVm.Criteria.SearchType().ToListingType(), MaxPrice = searchVm.MaxPrice, MinPrice = searchVm.MinPrice }; int?bathes = searchVm.Bathes; if (bathes.HasValue) { nullable1 = new long?((long)bathes.GetValueOrDefault()); } else { nullable = null; nullable1 = nullable; } communitySearchModel.BathroomFromId = nullable1; bathes = searchVm.Beds; if (bathes.HasValue) { nullable2 = new long?((long)bathes.GetValueOrDefault()); } else { nullable = null; nullable2 = nullable; } communitySearchModel.BedroomFromId = nullable2; communitySearchModel.AmenitiesIds = ( from a in searchVm.Amenities select(long) a).ToList <long>(); communitySearchModel.ShcCategoriesIds = ( from a in searchVm.ShcCategories select(long) a).ToList <long>(); return(communitySearchModel); }
internal static CommunityRefineVm MapToCommunityRefineVm(this CommunitiesSearchVm searchVm) { long?nullable; long?nullable1; long?nullable2; CommunityRefineVm communityRefineVm = new CommunityRefineVm(); List <KeyValuePair <int, string> > communityDefaultAmenities = ItemTypeBc.Instance.GetCommunityDefaultAmenities(); List <KeyValuePair <int, string> > shcCategoriesForCommunity = ItemTypeBc.Instance.GetShcCategoriesForCommunity(); List <KeyValuePair <int, string> > list = ItemTypeBc.Instance.GetBedrooms().Take <KeyValuePair <int, string> >(6).ToList <KeyValuePair <int, string> >(); List <KeyValuePair <int, string> > keyValuePairs = ( from pair in ItemTypeBc.Instance.GetBathrooms() where !pair.Value.Contains(".") select pair).Take <KeyValuePair <int, string> >(6).ToList <KeyValuePair <int, string> >(); communityRefineVm.Amenities = communityDefaultAmenities.MapToSelectListItemList(searchVm.Amenities); communityRefineVm.ShcCategories = shcCategoriesForCommunity.MapToSelectListItemList(searchVm.ShcCategories); List <KeyValuePair <int, string> > keyValuePairs1 = keyValuePairs; int?bathes = searchVm.Bathes; if (bathes.HasValue) { nullable1 = new long?((long)bathes.GetValueOrDefault()); } else { nullable = null; nullable1 = nullable; } communityRefineVm.Bathes = keyValuePairs1.ToSelectListItemList(nullable1); List <KeyValuePair <int, string> > keyValuePairs2 = list; bathes = searchVm.Beds; if (bathes.HasValue) { nullable2 = new long?((long)bathes.GetValueOrDefault()); } else { nullable = null; nullable2 = nullable; } communityRefineVm.Beds = keyValuePairs2.ToSelectListItemList(nullable2); communityRefineVm.SortTypes = ConverterHelper.EnumToKoSelectListItems <CommunitySortType>(searchVm.SortType); return(communityRefineVm); }
public static List <CommunityBlockVm> GetNewSmililarCommunity(CommunitiesSearchVm searchVm, long CommunityId) { Entities.Client.Search.FeaturedCommunitySearchModel searchModel2 = searchVm.ToFeaturedCommunitySearchModel(); searchModel2 = SearchBc.Instance.SearchFeaturedCommunities(searchModel2, CommunityId); return(searchModel2.Result.MapToCommunityBlockVmList(searchVm.Criteria.SearchType())); }
public static SeoVm GetSeo(CommunitiesSearchVm result) { SeoVm seoVm = new SeoVm() { PageType = result.PageType, CanonicalUrl = MslcUrlBuilder.PagingUrl((SearchVm)result, result.PageNumber), LinkPrev = SeoHelper.FormPageLink <CommunityBlockVm, CommunitySortType>(result, PageDirection.Previous), LinkNext = SeoHelper.FormPageLink <CommunityBlockVm, CommunitySortType>(result, PageDirection.Next), MarketCopy = SeoBc.Instance.GetCommunityMarketCopy(result.Criteria.ToSearchCriteria(), result.Criteria.SearchType().ToListingType()) }; switch (seoVm.PageType) { case PageType.ShcByState: { seoVm.Title = Title.SearchSHCByState; seoVm.Description = Description.SearchSHCByState; seoVm.Header = Header.SearchSHCByState; seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } case PageType.ShcByCity: { seoVm.Title = Title.SearchSHCByCity; seoVm.Description = Description.SearchSHCByCity; seoVm.Header = Header.SearchSHCByCity; seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } case PageType.ShcByZip: case PageType.AacByType: case PageType.AacByZip: case PageType.AahByType: { seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } case PageType.AacByState: { seoVm.Title = Title.SearchAACByState; seoVm.Description = Description.SearchAACByState; seoVm.Header = Header.SearchAACByState; seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } case PageType.AacByCity: { seoVm.Title = Title.SearchAACByCity; seoVm.Description = Description.SearchAACByCity; seoVm.Header = Header.SearchAACByCity; seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } case PageType.AahByState: { seoVm.Title = Title.SearchAAHByState; seoVm.Description = Description.SearchAAHByState; seoVm.Header = Header.SearchAAHByState; seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } case PageType.AahByCity: { seoVm.Title = Title.SearchAAHByCity; seoVm.Description = Description.SearchAAHByCity; seoVm.Header = Header.SearchAAHByCity; seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } default: { seoVm.Title = seoVm.Title.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Description = seoVm.Description.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.Header = seoVm.Header.Replace <CommunityBlockVm, CommunitySortType>(result); seoVm.MarketCopy = seoVm.MarketCopy.Replace <CommunityBlockVm, CommunitySortType>(result); return(seoVm); } } }
public static string GetLeadFormMessage(this CommunitiesSearchVm searchVm) { return(LeadFormMessages.Community.Replace("{COMMUNITY_NAME}", string.Empty)); }
private static IEnumerable <KeyValuePair <string, object> > RefinedParameters(CommunitiesSearchVm model) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(); if (model.Beds.HasValue) { routeValueDictionary.Add("beds", model.Beds); } if (model.Bathes.HasValue) { routeValueDictionary.Add("bathes", model.Bathes); } if (model.MinPrice.HasValue) { routeValueDictionary.Add("min-price", model.MinPrice); } if (model.MaxPrice.HasValue) { routeValueDictionary.Add("max-price", model.MaxPrice); } if (model.Amenities != null && model.Amenities.Any()) { routeValueDictionary.Add("amenities", string.Join("-", model.Amenities)); } if (model.ShcCategories != null && model.ShcCategories.Any()) { routeValueDictionary.Add("shc-categories", string.Join("-", model.ShcCategories)); } if (model.SortType != CommunitySortType.Featured && model.SortType != 0) { routeValueDictionary.Add("sort-by", model.SortType.ToSortTypeUrlStr()); } return(routeValueDictionary); }
private void BindListingsSearchModel(CommunitiesSearchVm model, ControllerContext controllerContext, PropertyDescriptor propertyDescriptor) { if (string.Equals(propertyDescriptor.Name, "Amenities")) { string text = controllerContext.HttpContext.Request["amenities"] ?? controllerContext.HttpContext.Request["Amenities"]; model.Amenities = new List <int>(); if (!string.IsNullOrWhiteSpace(text)) { model.Amenities = (from pair in text.Split('-', ',').Select(delegate(string str) { int result6; bool success2 = int.TryParse(str, out result6); return(new { value = result6, success = success2 }); }) where pair.success select pair.value).Distinct().ToList(); return; } } if (string.Equals(propertyDescriptor.Name, "ShcCategories")) { string text2 = controllerContext.HttpContext.Request["shc-categories"] ?? controllerContext.HttpContext.Request["ShcCategories"]; model.ShcCategories = new List <int>(); if (!string.IsNullOrWhiteSpace(text2)) { model.ShcCategories = (from pair in text2.Split('-', ',').Select(delegate(string str) { int result5; bool success = int.TryParse(str, out result5); return(new { value = result5, success = success }); }) where pair.success select pair.value).Distinct().ToList(); return; } } int result2; int result3; int result4; if (string.Equals(propertyDescriptor.Name, "MinPrice") && int.TryParse(controllerContext.HttpContext.Request["min-price"] ?? controllerContext.HttpContext.Request["MinPrice"], out var result)) { model.MinPrice = result; } else if (string.Equals(propertyDescriptor.Name, "MaxPrice") && int.TryParse(controllerContext.HttpContext.Request["max-price"] ?? controllerContext.HttpContext.Request["MaxPrice"], out result2)) { model.MaxPrice = result2; } else if (string.Equals(propertyDescriptor.Name, "Beds") && int.TryParse(controllerContext.HttpContext.Request["beds"] ?? controllerContext.HttpContext.Request["Beds"], out result3)) { model.Beds = result3; } else if (string.Equals(propertyDescriptor.Name, "Bathes") && int.TryParse(controllerContext.HttpContext.Request["bathes"] ?? controllerContext.HttpContext.Request["Bathes"], out result4)) { model.Bathes = result4; } else if (string.Equals(propertyDescriptor.Name, "SortType")) { string sortType = controllerContext.HttpContext.Request["sort-by"] ?? controllerContext.HttpContext.Request["SortType"]; model.SortType = sortType.FromCommunitySortTypeUrlStr(); } }