private static UrlProcessingResult CheckForOldUrl(string url, out string newUrl) { newUrl = null; Match match = OldDetails.Match(url); if (match.Success) { if (TryParseToPropertyType(match.Groups["searchType"].Value, out var type)) { if (type == SearchType.ProductsAndServices) { ServiceProviderShortVm serviceProviderShortVm = new ServiceProviderShortVm(); serviceProviderShortVm.Id = Convert.ToInt64(match.Groups["listingId"].Value); serviceProviderShortVm.Name = match.Groups["listingName"].Value; serviceProviderShortVm.Address = new AddressVm(); serviceProviderShortVm.Address.StateCode = match.Groups["stateCode"].Value; serviceProviderShortVm.Address.City = match.Groups["city"].Value; newUrl = MslcUrlBuilder.DetailsUrl(serviceProviderShortVm); } else { CommunityShortVm communityShortVm = new CommunityShortVm(); communityShortVm.Id = Convert.ToInt64(match.Groups["listingId"].Value); communityShortVm.Name = match.Groups["listingName"].Value; communityShortVm.Address = new AddressVm(); communityShortVm.Address.StateCode = match.Groups["stateCode"].Value; communityShortVm.Address.City = match.Groups["city"].Value; newUrl = MslcUrlBuilder.DetailsUrl(communityShortVm, type); } if (!newUrl.IsNullOrEmpty()) { return(UrlProcessingResult.RedirectPermanent); } return(UrlProcessingResult.NotFound); } return(UrlProcessingResult.NotFound); } Match match2 = OldSearch.Match(url); if (match2.Success) { if (TryParseToPropertyType(match2.Groups["searchType"].Value, out var type2)) { SearchCriteria criteria = new SearchCriteria(); criteria.StateCode(match2.Groups["stateCode"].Value); criteria.City(match2.Groups["city"].Value); newUrl = MslcUrlBuilder.SearchUrl(criteria, type2); if (!newUrl.IsNullOrEmpty()) { return(UrlProcessingResult.RedirectPermanent); } return(UrlProcessingResult.NotFound); } return(UrlProcessingResult.NotFound); } return(UrlProcessingResult.Continue); }
private static CommunityShortVm MapToCommunityShortVm(this Community community, SearchType searchType, CommunityShortVm viewModel) { CommunityShortVm id = viewModel ?? new CommunityShortVm(); id.Id = community.Id; id.BookNumber = community.BookNumber; id.Name = community.Name; id.Price = community.Price.PriceCaption(id.Name); id.PhotoCount = community.Images.Count <Image>((Image i) => i.Type == ImageType.Image); id.Image = community.Images.FirstOrDefault <Image>((Image i) => i.Type == ImageType.Image).MapToImageVm(ImageOwner.Community, id.Name); id.Address = community.Address.MapToAddressVm(); id.DetailsUrl = MslcUrlBuilder.DetailsUrl(id, searchType); id.DisplayProperties = new CommunityDisplayProperties(community.DisplayOptions); id.Package = (int)community.PackageId; return(id); }
public static string GetLeadFormMessage(this CommunityShortVm community) { return(LeadFormMessages.Community.Replace("{COMMUNITY_NAME}", !community.Name.IsNullOrWhitespace(), community.Name)); }