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 ServiceProviderShortVm MapToServiceProviderShortVm(this ServiceProvider serviceProvider, ServiceProviderShortVm viewModel) { ServiceProviderShortVm id = viewModel ?? new ServiceProviderShortVm(); id.Id = serviceProvider.Id; id.BookNumber = serviceProvider.BookNumber; id.Name = serviceProvider.Name; id.PhotoCount = serviceProvider.Images.Count <Image>((Image i) => i.Type == ImageType.Image); id.Image = serviceProvider.Images.FirstOrDefault <Image>((Image i) => i.Type == ImageType.Image).MapToImageVm(ImageOwner.Service, id.Name); id.Address = serviceProvider.Address.MapToAddressVm(); id.DetailsUrl = MslcUrlBuilder.DetailsUrl(id); id.DisplayProperties = new ServiceProviderDisplayProperties(serviceProvider.DisplayOptions); id.Package = (int)serviceProvider.PackageId; return(id); }
public static string GetLeadFormMessage(this ServiceProviderShortVm serviceProvider) { return(LeadFormMessages.ServiceProvider.Replace("{SERVICE_PROVIDER_NAME}", !serviceProvider.Name.IsNullOrWhitespace(), serviceProvider.Name)); }