private static SearchBarVm FillSearchTemplates(SearchBarVm searchBar)
        {
            List <SearchTemplates> searchTemplates = ConfigurationManager.Instance.SearchTemplates;

            if (searchTemplates.Any((SearchTemplates t) => t.CountryCode.Equals("USA", StringComparison.InvariantCultureIgnoreCase)))
            {
                SearchTemplates searchTemplates2 = searchTemplates.First((SearchTemplates t) => t.CountryCode.Equals("USA", StringComparison.InvariantCultureIgnoreCase));
                searchBar.Placeholder = searchTemplates2.Placeholder;
                searchBar.Templates   = new Dictionary <SearchType, List <AutocompleteVm> >();
                SearchType[] array = (SearchType[])Enum.GetValues(typeof(SearchType));
                foreach (SearchType searchType in array)
                {
                    List <AutocompleteVm> list = new List <AutocompleteVm>();
                    foreach (QueryTemplate template in searchTemplates2.Templates)
                    {
                        AutocompleteVm autocompleteVm = new AutocompleteVm();
                        autocompleteVm.Start    = template.LookupLocation;
                        autocompleteVm.Template = template.Template;
                        autocompleteVm.Url      = MslcUrlBuilder.AbsoluteUrl($"/{searchType.UrlPrefix()}{template.Url}");
                        list.Add(autocompleteVm);
                    }
                    searchBar.Templates.Add(searchType, list);
                }
            }
            return(searchBar);
        }
Exemple #2
0
 public Owner ToEntity(MSLivingChoices.Entities.Admin.Enums.OwnerType ownerType)
 {
     return(new Owner()
     {
         Id = this.Id,
         Name = this.Name,
         OwnerType = ownerType,
         Address = this.Address.ToEntity(),
         Phones = this.PhoneList.ToEntityList(),
         Emails = this.EmailList.ToEntity(),
         Contacts = this.Contacts.ConvertAll <Contact>((ContactVm m) => m.ToEntity()).Where <Contact>((Contact x) => {
             if (!string.IsNullOrWhiteSpace(x.FirstName))
             {
                 return true;
             }
             return !string.IsNullOrWhiteSpace(x.LastName);
         }).ToList <Contact>(),
         WebsiteUrl = MslcUrlBuilder.NormalizeUri(this.WebsiteUrl),
         DisplayWebsiteUrl = this.DisplayWebsiteUrl,
         DisplayName = this.DisplayName,
         DisplayAddress = this.DisplayAddress,
         DisplayPhone = this.DisplayPhone,
         DisplayLogo = this.DisplayLogo,
         LogoImages = (this.LogoImages != null ? this.LogoImages.ToEntity(ImageType.Logo) : new List <Image>())
     });
 }
        private static List <LinkVm> GetBreadcrumbs(ServiceProviderDetailsVm serviceProviderDetails)
        {
            List <LinkVm> breadcrumbs = GetBreadcrumbs((SearchVm)serviceProviderDetails);

            breadcrumbs.Add(new LinkVm(serviceProviderDetails.ServiceProvider.Name, MslcUrlBuilder.DetailsUrl(serviceProviderDetails.ServiceProvider)));
            return(breadcrumbs);
        }
        private static List <LinkVm> GetBreadcrumbs(CommunityDetailsVm communityDetails)
        {
            List <LinkVm> breadcrumbs = GetBreadcrumbs((SearchVm)communityDetails);

            breadcrumbs.Add(new LinkVm(communityDetails.Community.Name, MslcUrlBuilder.DetailsUrl(communityDetails.Community, communityDetails.Criteria.SearchType())));
            return(breadcrumbs);
        }
        internal static List <AutocompleteVm> MapToAutocompleteVmList(this IEnumerable <SearchCriteria> criterias, SearchType searchType, string lookupString)
        {
            List <AutocompleteVm> autocompleteVms = new List <AutocompleteVm>();

            foreach (SearchCriteria criteria in criterias)
            {
                AutocompleteVm autocompleteVm = new AutocompleteVm();
                string         lookupLocation = ClientViewModelsProvider.GetLookupLocation(criteria);
                if (lookupString.IsNullOrEmpty() || !lookupLocation.StartsWith(lookupString, StringComparison.InvariantCultureIgnoreCase))
                {
                    autocompleteVm.Start = lookupLocation;
                }
                else
                {
                    autocompleteVm.Start = new string(lookupLocation.Take <char>(lookupString.Count <char>()).ToArray <char>());
                    autocompleteVm.End   = new string(lookupLocation.Skip <char>(lookupString.Count <char>()).ToArray <char>());
                }
                if (string.IsNullOrEmpty(autocompleteVm.LookupLocation))
                {
                    continue;
                }
                autocompleteVm.Url = MslcUrlBuilder.SearchUrl(criteria, searchType);
                SearchDepth depth = criteria.Depth;
                switch (depth)
                {
                case SearchDepth.State:
                {
                    autocompleteVm.Template = "State";
                    break;
                }

                case SearchDepth.City:
                {
                    autocompleteVm.Template = "City";
                    break;
                }

                case SearchDepth.Zip:
                {
                    autocompleteVm.Template = "Zip";
                    break;
                }

                default:
                {
                    depth = SearchDepth.Invalid;
                    break;
                }
                }
                if (depth == SearchDepth.Invalid)
                {
                    continue;
                }
                autocompleteVms.Add(autocompleteVm);
            }
            return(autocompleteVms);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        private static string GetServiceDetailsUrl(long id)
        {
            ServiceProvider serviceProvider = SearchBc.Instance.GetServiceProvider(id);

            if (serviceProvider == null)
            {
                return(null);
            }
            return(MslcUrlBuilder.DetailsUrl(serviceProvider));
        }
Exemple #8
0
        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);
        }
        private static void PopulateFeaturedServices(this SearchWithServicesVm searchVm, long?communityId = null, long?serviceId = null)
        {
            FeaturedServiceProviderSearchModel searchModel = searchVm.ToFeaturedServiceProviderSearchModel(communityId, serviceId);

            searchModel = SearchBc.Instance.SearchFeaturedServiceProviders(searchModel);
            searchVm.FeaturedServices                  = new FeaturedServicesVm();
            searchVm.FeaturedServices.AreaName         = searchVm.SearchBar.LookupLocation;
            searchVm.FeaturedServices.Items            = searchModel.Result.MapToServiceProviderShortVmList();
            searchVm.FeaturedServices.AreaServicesLink = MslcUrlBuilder.SearchUrl(searchVm.Criteria, SearchType.ProductsAndServices);
        }
Exemple #10
0
        private static string GetCommunityDetailsUrl(long id)
        {
            string    result    = null;
            Community community = SearchBc.Instance.GetCommunity(id);

            if (community != null && community.ListingTypes.Any())
            {
                result = MslcUrlBuilder.DetailsUrl(community, community.ListingTypes.ToSearchType());
            }
            return(result);
        }
        internal static List <LinkVm> MapToCitiesLinks(this IEnumerable <CityListingsInfo> cities, SearchType searchType, bool addCounting)
        {
            string str = (addCounting ? "{0}, {1} ({2})" : "{0}, {1}");

            return(cities.Select <CityListingsInfo, LinkVm>((CityListingsInfo cityInfo) => {
                LinkVm linkVm = new LinkVm();
                int listingsCount = SearchExtentions.GetListingsCount(cityInfo, searchType);
                linkVm.Href = MslcUrlBuilder.SearchUrl(cityInfo.SearchCriteria, searchType);
                linkVm.InnerText = string.Format(str, cityInfo.SearchCriteria.City(), cityInfo.SearchCriteria.StateCode(), listingsCount);
                return linkVm;
            }).ToList <LinkVm>());
        }
Exemple #12
0
        public Image ToEntity(ImageType imageType)
        {
            string url = MslcUrlBuilder.ImageHandlerUrl(this);

            return(new Image()
            {
                Id = this.Id,
                Name = this.Name,
                Url = url,
                ImageType = imageType
            });
        }
        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);
        }
        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);
        }
        private static ServiceProviderBlockVm MapToServiceProviderBlockVm(this ServiceProvider serviceProvider, ServiceProviderBlockVm viewModel)
        {
            ServiceProviderBlockVm serviceProviderShortVm = serviceProvider.MapToServiceProviderShortVm(viewModel ?? new ServiceProviderBlockVm()) as ServiceProviderBlockVm;

            if (serviceProviderShortVm != null)
            {
                serviceProviderShortVm.Description       = serviceProvider.Description;
                serviceProviderShortVm.CountiesServed    = serviceProvider.CountiesServed;
                serviceProviderShortVm.ServiceCategories = serviceProvider.ServiceCategories;
                serviceProviderShortVm.Images            = (serviceProvider.Images.Any <Image>((Image i) => i.Type == ImageType.Image) ? (
                                                                from i in serviceProvider.Images
                                                                where i.Type == ImageType.Image
                                                                select i).ToList <Image>().ConvertAll <ImageVm>((Image i) => i.MapToImageVm(ImageOwner.Service, serviceProviderShortVm.Name)) : new List <ImageVm>());
                serviceProviderShortVm.Phone = serviceProvider.Phone;
                serviceProviderShortVm.SearchRadiusDesignation = (serviceProvider.SearchResultRadius > 0 ? string.Format(StaticContent.Txt_SearchRadiusDesignation, serviceProvider.SearchResultRadius) : string.Empty);
                serviceProviderShortVm.PrintUrl = MslcUrlBuilder.PrintUrl(serviceProvider);
                serviceProviderShortVm.PrintDirectionBaseUrl = MslcUrlBuilder.PrintDirectionBaseUrl(serviceProvider);
            }
            return(serviceProviderShortVm);
        }
        private static CommunityDetailsVm MapToCommunityDetailsVm(this Community community, PageType pageType, CommunityDetailsVm viewModel)
        {
            ImageVm            imageVm;
            CommunityDetailsVm communityQuickViewVm = viewModel ?? new CommunityDetailsVm();

            communityQuickViewVm.PageType       = pageType;
            communityQuickViewVm.Community      = community.MapToCommunityQuickViewVm(pageType.ToSearchType());
            communityQuickViewVm.Criteria       = communityQuickViewVm.Community.Address.MapToSearchCriteriaVm(pageType.ToSearchType());
            communityQuickViewVm.Deposit        = community.Deposit.PriceCaption();
            communityQuickViewVm.ApplicationFee = community.ApplicationFee.PriceCaption();
            communityQuickViewVm.PetDeposit     = community.PetDeposit.PriceCaption();
            communityQuickViewVm.VirtualTourUrl = community.VirtualTour.ExternalUrl();
            communityQuickViewVm.WebsiteUrl     = community.WebsiteUrl.ExternalUrl();
            CommunityDetailsVm communityDetailsVm = communityQuickViewVm;

            if (community.Images.Any <Image>((Image i) => i.Type == ImageType.Logo))
            {
                imageVm = community.Images.First <Image>((Image i) => i.Type == ImageType.Logo).MapToImageVm(ImageOwner.Community, string.Format("{0} Logo", communityQuickViewVm.Community.Name));
            }
            else
            {
                imageVm = null;
            }
            communityDetailsVm.Logo = imageVm;
            communityQuickViewVm.AgeRestrictions  = community.AgeRestrictions.Select <AgeRestriction, string>(new Func <AgeRestriction, string>(LocalizationExtensions.GetEnumLocalizedValue <AgeRestriction>)).ToList <string>();
            communityQuickViewVm.ShcCategories    = community.ShcCategories;
            communityQuickViewVm.PaymentsAccepted = community.AcceptedPayments;
            communityQuickViewVm.FloorPlans       = community.FloorPlans.MapToFloorPlanVmList();
            communityQuickViewVm.SpecHomes        = community.SpecHomes.MapToSpecHomeVmList();
            communityQuickViewVm.Homes            = community.Homes.MapToHomeVmList();
            communityQuickViewVm.Coupon           = community.Coupon.MapToCouponVm(MslcUrlBuilder.PrintCouponUrl(community, communityQuickViewVm.Criteria.SearchType()));
            communityQuickViewVm.Pmc         = community.Pmc.MapToOwnerVm(communityQuickViewVm.Community.Package);
            communityQuickViewVm.OfficeHours = (
                from oh in community.OfficeHours
                select oh.ToString()).ToList <string>();
            communityQuickViewVm.DisplayProperties = new DetailsDisplayProperties();
            return(communityQuickViewVm);
        }
        internal static CrosslinksVm MapToCrosslinksVm(this NearbySearchResult searchResult, ISearchCriteria sourceCriteria)
        {
            CrosslinksVm crosslinksVm = new CrosslinksVm();

            foreach (SearchCriteria nearbyCity in searchResult.NearbyCities)
            {
                if (!nearbyCity.MapToSearchCriteriaVm().Validate())
                {
                    continue;
                }
                LinkVm linkVm = new LinkVm()
                {
                    InnerText = ClientViewModelsProvider.GetLookupLocation(nearbyCity),
                    Href      = MslcUrlBuilder.SearchUrl(nearbyCity, sourceCriteria.SearchType())
                };
                crosslinksVm.Cities.Add(linkVm);
            }
            foreach (ListingType availableListingType in searchResult.AvailableListingTypes)
            {
                LinkVm linkVm1 = new LinkVm()
                {
                    InnerText = availableListingType.GetEnumLocalizedValue <ListingType>(),
                    Href      = MslcUrlBuilder.SearchUrl(sourceCriteria, availableListingType.ToSearchType())
                };
                crosslinksVm.Categories.Add(linkVm1);
            }
            if (searchResult.IsServiceProvidersAvailable)
            {
                LinkVm linkVm2 = new LinkVm()
                {
                    InnerText = "Products & Services",
                    Href      = MslcUrlBuilder.SearchUrl(sourceCriteria, SearchType.ProductsAndServices)
                };
                crosslinksVm.Categories.Add(linkVm2);
            }
            return(crosslinksVm);
        }
        private static List <LinkVm> GetBreadcrumbs(SearchVm searchVm)
        {
            List <LinkVm> list = new List <LinkVm>();

            list.Add(new LinkVm("Home", MslcUrlBuilder.BaseUrl));
            if (searchVm.PageType.IsStaticPage())
            {
                if (searchVm.Seo != null)
                {
                    list.Add(new LinkVm(searchVm.Seo.Header, searchVm.Seo.CanonicalUrl));
                }
                return(list);
            }
            if (searchVm.Criteria.Validate())
            {
                SearchCriteriaVm criteria = new SearchCriteriaVm();
                criteria.SearchType(searchVm.Criteria.SearchType());
                list.Add(new LinkVm(criteria.SearchType().GetEnumLocalizedValue(), MslcUrlBuilder.SearchUrl(criteria, criteria.SearchType())));
                if (!searchVm.Criteria.StateCode().IsNullOrEmpty())
                {
                    criteria.StateCode(searchVm.Criteria.StateCode());
                    list.Add(new LinkVm(LocationBc.Instance.GetStateName(criteria.StateCode()), MslcUrlBuilder.SearchUrl(criteria, criteria.SearchType())));
                }
                if (!searchVm.Criteria.City().IsNullOrEmpty())
                {
                    criteria.City(searchVm.Criteria.City());
                    list.Add(new LinkVm(criteria.City(), MslcUrlBuilder.SearchUrl(criteria, criteria.SearchType())));
                }
                else if (!searchVm.Criteria.Zip().IsNullOrEmpty())
                {
                    criteria.Zip(searchVm.Criteria.Zip());
                    list.Add(new LinkVm(criteria.Zip(), MslcUrlBuilder.SearchUrl(criteria, criteria.SearchType())));
                }
            }
            return(list);
        }
        private static SearchBarVm FillSearchTypeList(SearchBarVm searchBar, SearchVm searchVm)
        {
            List <SearchType> list       = ConverterHelper.EnumToList <SearchType>();
            SearchType        searchType = searchVm.Criteria.SearchType();

            searchBar.SearchTypeList = new List <SearchBarSelectListItem>();
            NearbySearchResult nearbySearchResult = GetNearbySearchResult(searchVm);

            if (nearbySearchResult != null)
            {
                searchBar.Crosslinks = nearbySearchResult.MapToCrosslinksVm(searchVm.Criteria);
            }
            foreach (SearchType item in list)
            {
                SearchBarSelectListItem searchBarSelectListItem = new SearchBarSelectListItem();
                searchBarSelectListItem.Text = item.GetEnumLocalizedValue();
                int num = (int)item;
                searchBarSelectListItem.Value    = num.ToString(CultureInfo.InvariantCulture);
                searchBarSelectListItem.Selected = item == searchType;
                ListingType type;
                if (nearbySearchResult == null)
                {
                    searchBarSelectListItem.UrlValue = MslcUrlBuilder.SearchUrl(searchVm.Criteria, item);
                }
                else if (item.TryToListingType(out type))
                {
                    searchBarSelectListItem.UrlValue = MslcUrlBuilder.SearchUrl(nearbySearchResult.AvailableListingTypes.Contains(type) ? searchVm.Criteria : searchVm.Criteria.CloneLowerDepth(), item);
                }
                else
                {
                    searchBarSelectListItem.UrlValue = MslcUrlBuilder.SearchUrl(nearbySearchResult.IsServiceProvidersAvailable ? searchVm.Criteria : searchVm.Criteria.CloneLowerDepth(), item);
                }
                searchBar.SearchTypeList.Add(searchBarSelectListItem);
            }
            return(searchBar);
        }
        private static CommunityBlockVm MapToCommunityBlockVm(this Community community, SearchType searchType, CommunityBlockVm viewModel)
        {
            CommunityBlockVm communityShortVm = community.MapToCommunityShortVm(searchType, viewModel ?? new CommunityBlockVm()) as CommunityBlockVm;

            if (communityShortVm != null)
            {
                communityShortVm.Description  = community.Description;
                communityShortVm.ListingTypes = community.ListingTypes;
                communityShortVm.Bathes       = community.Bathes.BathesCaption();
                communityShortVm.Beds         = community.Beds.BedsCaption();
                communityShortVm.Area         = community.LivingSpace.AreaCaption();
                communityShortVm.Amenities    = community.Amenities;
                communityShortVm.Images       = (community.Images.Any <Image>((Image i) => i.Type == ImageType.Image) ? (
                                                     from i in community.Images
                                                     where i.Type == ImageType.Image
                                                     select i).ToList <Image>().ConvertAll <ImageVm>((Image i) => i.MapToImageVm(ImageOwner.Community, communityShortVm.Name)) : new List <ImageVm>());
                communityShortVm.Phone = community.Phone;
                communityShortVm.SearchRadiusDesignation = (community.SearchResultRadius > 0 ? string.Format(StaticContent.Txt_SearchRadiusDesignation, community.SearchResultRadius) : string.Empty);
                communityShortVm.PrintUrl = MslcUrlBuilder.PrintUrl(community, searchType);
                communityShortVm.PrintDirectionBaseUrl = MslcUrlBuilder.PrintDirectionBaseUrl(community, searchType);
                communityShortVm.SHC = community.ShcCategories;
            }
            return(communityShortVm);
        }
        public virtual ServiceProvider ToEntity()
        {
            long            id;
            ServiceProvider serviceProvider = new ServiceProvider();
            List <long>     paymentTypeIds  = new List <long>();

            foreach (CheckBoxVm checkBoxVm in
                     from m in this.PaymentTypes
                     where m.IsChecked
                     select m)
            {
                if (!long.TryParse(checkBoxVm.Value, out id))
                {
                    continue;
                }
                paymentTypeIds.Add(id);
            }
            serviceProvider.PaymentTypeIds = paymentTypeIds;
            serviceProvider.Coupon         = this.Coupon.ToEntity();
            serviceProvider.Package        = this.Package;
            serviceProvider.Book           = new Book()
            {
                Id = this.BookId
            };
            serviceProvider.ServiceCategories = (
                from key in ConverterHelpers.CheckBoxListToLongArray(this.ServiceCategories)
                select new KeyValuePair <long, string>(key, string.Empty)).ToList <KeyValuePair <long, string> >();
            serviceProvider.AllCounties    = this.AllCounties;
            serviceProvider.CountiesServed = this.CountiesServed;
            serviceProvider.Name           = this.Name;
            serviceProvider.Address        = (this.AddressValidation.ValidationItems == null ? this.Address.ToEntity() : this.AddressValidation.ToEntity());
            serviceProvider.DisplayAddress = !this.DoNotDisplayAddress;
            serviceProvider.Phones         = this.PhoneList.ToEntityList();
            serviceProvider.Emails         = this.EmailList.ToEntity();
            serviceProvider.Contacts       = this.Contacts.ConvertAll <Contact>((ContactVm m) => m.ToEntity()).Where <Contact>((Contact x) => {
                if (!string.IsNullOrWhiteSpace(x.FirstName))
                {
                    return(true);
                }
                return(!string.IsNullOrWhiteSpace(x.LastName));
            }).ToList <Contact>();
            serviceProvider.OfficeHours        = this.OfficeHours.ConvertAll <MSLivingChoices.Entities.Admin.OfficeHours>((OfficeHoursVm m) => m.ToEntity());
            serviceProvider.Description        = this.Description;
            serviceProvider.WebsiteUrl         = MslcUrlBuilder.NormalizeUri(this.WebsiteUrl);
            serviceProvider.DisplayWebsiteUrl  = this.DisplayWebsiteUrl;
            serviceProvider.FeatureStartDate   = this.FeatureStartDate;
            serviceProvider.FeatureEndDate     = this.FeatureEndDate;
            serviceProvider.PublishStartDate   = this.PublishStartDate;
            serviceProvider.PublishEndDate     = this.PublishEndDate;
            serviceProvider.Images             = (this.Images != null ? this.Images.ToEntity(ImageType.Photo) : new List <Image>());
            serviceProvider.CallTrackingPhones = new List <CallTrackingPhone>();
            if (this.CallTrackingPhones != null)
            {
                if (!this.ProvisionCallTrackingNumbers)
                {
                    this.CallTrackingPhones.ForEach((CallTrackingPhoneVm c) => c.IsDisconnected = true);
                }
                serviceProvider.CallTrackingPhones = (
                    from p in this.CallTrackingPhones.ConvertAll <CallTrackingPhone>((CallTrackingPhoneVm m) => m.ToEntity())
                    where !string.IsNullOrEmpty(p.Phone)
                    select p).ToList <CallTrackingPhone>();
            }
            return(serviceProvider);
        }
        private static ServiceProviderDetailsVm MapToServiceProviderDetailsVm(this ServiceProvider serviceProvider, ServiceProviderDetailsVm viewModel)
        {
            ServiceProviderDetailsVm serviceProviderQuickViewVm = viewModel ?? new ServiceProviderDetailsVm();

            serviceProviderQuickViewVm.PageType        = PageType.ServiceProviderDetails;
            serviceProviderQuickViewVm.ServiceProvider = serviceProvider.MapToServiceProviderQuickViewVm();
            serviceProviderQuickViewVm.Criteria        = serviceProviderQuickViewVm.ServiceProvider.Address.MapToSearchCriteriaVm(SearchType.ProductsAndServices);
            serviceProviderQuickViewVm.Coupon          = serviceProvider.Coupon.MapToCouponVm(MslcUrlBuilder.PrintCouponUrl(serviceProvider));
            serviceProviderQuickViewVm.OfficeHours     = (
                from oh in serviceProvider.OfficeHours
                select oh.ToString()).ToList <string>();
            serviceProviderQuickViewVm.WebsiteUrl        = serviceProvider.WebsiteUrl.ExternalUrl();
            serviceProviderQuickViewVm.PaymentsAccepted  = serviceProvider.AcceptedPayments;
            serviceProviderQuickViewVm.DisplayProperties = new DetailsDisplayProperties();
            return(serviceProviderQuickViewVm);
        }
        internal static LookupLocationValidationVm MapToLookupLocationValidationVm(this LookupLocationValidationResult validationResult, SearchType searchType)
        {
            LookupLocationValidationVm lookupLocationValidationVm = new LookupLocationValidationVm();

            if (validationResult.IsValid && validationResult.Criteria.Depth == SearchDepth.Zip)
            {
                SearchCriteria searchCriterium = new SearchCriteria();
                searchCriterium.CountryCode(validationResult.Criteria.CountryCode());
                searchCriterium.StateCode(validationResult.Criteria.StateCode());
                if (!validationResult.Criteria.City().IsNullOrEmpty())
                {
                    searchCriterium.City(validationResult.Criteria.City());
                }
                validationResult.Criteria = searchCriterium;
            }
            lookupLocationValidationVm.IsValid   = validationResult.IsValid;
            lookupLocationValidationVm.Criteria  = (lookupLocationValidationVm.IsValid ? validationResult.Criteria.MapToSearchCriteriaVm(searchType) : new SearchCriteriaVm());
            lookupLocationValidationVm.Variants  = (lookupLocationValidationVm.IsValid ? new List <AutocompleteVm>() : validationResult.Variants.MapToAutocompleteVmList(searchType, string.Empty));
            lookupLocationValidationVm.SearchUrl = (lookupLocationValidationVm.IsValid ? MslcUrlBuilder.SearchUrl(validationResult.Criteria, searchType) : string.Empty);
            return(lookupLocationValidationVm);
        }
        public virtual Community ToEntity()
        {
            long      id;
            Community community = new Community()
            {
                Book = new Book()
                {
                    Id = this.BookId
                },
                Package      = this.Package,
                ListingTypes = ConverterHelpers.CheckBoxListToEnumList <ListingType>(this.ListingTypes),
                SeniorHousingAndCareCategoryIds = ConverterHelpers.CheckBoxListToLongArray(this.SeniorHousingAndCareCategories),
                AgeRestrictions = ConverterHelpers.CheckBoxListToEnumList <AgeRestriction>(this.AgeRestrictions),
                Name            = this.Name,
                Address         = (this.AddressValidation.ValidationItems == null ? this.Address.ToEntity() : this.AddressValidation.ToEntity()),
                DisplayAddress  = !this.DoNotDisplayAddress,
                Phones          = this.PhoneList.ToEntityList(),
                Emails          = this.EmailList.ToEntity(),
                Contacts        = this.Contacts.ConvertAll <Contact>((ContactVm m) => m.ToEntity()).Where <Contact>((Contact x) => {
                    if (!string.IsNullOrWhiteSpace(x.FirstName))
                    {
                        return(true);
                    }
                    return(!string.IsNullOrWhiteSpace(x.LastName));
                }).ToList <Contact>(),
                OfficeHours = (
                    from m in this.OfficeHours
                    select m.ToEntity()).ToList <MSLivingChoices.Entities.Admin.OfficeHours>(),
                Description       = this.Description,
                WebsiteUrl        = MslcUrlBuilder.NormalizeUri(this.WebsiteUrl),
                DisplayWebsiteUrl = this.DisplayWebsiteUrl
            };
            List <long> paymentTypeIds = new List <long>();

            foreach (CheckBoxVm checkBoxVm in
                     from m in this.CommunityDetails.PaymentTypes
                     where m.IsChecked
                     select m)
            {
                if (!long.TryParse(checkBoxVm.Value, out id))
                {
                    continue;
                }
                paymentTypeIds.Add(id);
            }
            community.PaymentTypeIds    = paymentTypeIds;
            community.PriceRange        = this.CommunityDetails.PriceRange.ToEntity();
            community.Deposit           = this.CommunityDetails.Deposit.ToEntity();
            community.ApplicationFee    = this.CommunityDetails.ApplicationFee.ToEntity();
            community.PetDeposit        = this.CommunityDetails.PetDeposit.ToEntity();
            community.BedroomFromId     = this.CommunityDetails.BedroomFromId;
            community.BedroomToId       = this.CommunityDetails.BedroomToId;
            community.BathroomFromId    = this.CommunityDetails.BathroomFromId;
            community.BathroomToId      = this.CommunityDetails.BathroomToId;
            community.LivingSpace       = this.CommunityDetails.LivingSpace.ToEntity();
            community.UnitCount         = this.CommunityDetails.UnitCount;
            community.Amenities         = AmenityVm.ToEntityList(this.CommunityDetails.DefaultAmenities, this.CommunityDetails.CustomAmenities);
            community.CommunityServices = CommunityServiceVm.ToEntityList(this.CommunityDetails.DefaultCommunityServices, this.CommunityDetails.CustomCommunityServices);
            community.FloorPlans        = new List <FloorPlan>();
            community.SpecHomes         = new List <SpecHome>();
            community.Houses            = new List <House>();
            community.VirtualTour       = MslcUrlBuilder.NormalizeUri(this.CommunityDetails.VirtualTour);
            community.Coupon            = this.CommunityDetails.Coupon.ToEntity();
            community.Images            = (this.CommunityDetails.Images == null ? new List <Image>() : this.CommunityDetails.Images.ToEntity(ImageType.Photo));
            community.LogoImages        = (this.CommunityDetails.LogoImages == null ? new List <Image>() : this.CommunityDetails.LogoImages.ToEntity(ImageType.Logo));
            if (this.CommunityDetails.HasFloorPlans)
            {
                community.FloorPlans = (
                    from m in this.CommunityDetails.FloorPlans
                    select m.ToEntity()).ToList <FloorPlan>();
                community.FloorPlans.ForEach((FloorPlan m) => m.Community = community);
            }
            if (this.CommunityDetails.HasSpecHomes)
            {
                community.SpecHomes = (
                    from m in this.CommunityDetails.SpecHomes
                    select m.ToEntity()).ToList <SpecHome>();
                community.SpecHomes.ForEach((SpecHome m) => m.Community = community);
            }
            if (this.CommunityDetails.HasHouses)
            {
                community.Houses = (
                    from m in this.CommunityDetails.Houses
                    select m.ToEntity()).ToList <House>();
                community.Houses.ForEach((House m) => m.Community = community);
            }
            community.PropertyManager    = this.ListingDetails.PropertyManager.ToEntity(OwnerType.PropertyManager);
            community.Builder            = this.ListingDetails.Builder.ToEntity(OwnerType.Builder);
            community.CallTrackingPhones = new List <CallTrackingPhone>();
            if (this.ListingDetails.CallTrackingPhones != null)
            {
                if (!this.ListingDetails.ProvisionCallTrackingNumbers)
                {
                    this.ListingDetails.CallTrackingPhones.ForEach((CallTrackingPhoneVm c) => c.IsDisconnected = true);
                }
                community.CallTrackingPhones = (
                    from p in this.ListingDetails.CallTrackingPhones.ConvertAll <CallTrackingPhone>((CallTrackingPhoneVm x) => x.ToEntity())
                    where !string.IsNullOrEmpty(p.Phone)
                    select p).ToList <CallTrackingPhone>();
            }
            community.Publishing.StartDate = this.PublishStart;
            community.Publishing.EndDate   = this.PublishEnd;
            community.Showcase.StartDate   = this.ShowcaseStart;
            community.Showcase.EndDate     = this.ShowcaseEnd;
            return(community);
        }