Exemplo n.º 1
0
        public DataWrapper GetCustomFilterGroupDataByVehicleAttributeName([FromBody] string queryStr)
        {
            var query = JsonConvert.DeserializeObject <VehicleAttributeFilterQuery>(queryStr);
            var vehicleAttributeName = query.VehicleAttributeSeoName;

            var vehicleAttributeTranslator = UriTokenTranslators.GetVehicleAttributeTranslatorBySeoName(vehicleAttributeName);
            var vehicleAttributeSeoName    = vehicleAttributeTranslator.SeoName;

            try
            {
                var categoryFilterGroups = VehicleSpecService.GetCustomFilterGroupDataByVehicleAttributeNameAsync(vehicleAttributeSeoName).Result;
                if (categoryFilterGroups != null)
                {
                    var queryResults = categoryFilterGroups;

                    var response = new CategoryFilterGroupResponse
                    {
                        CategoryFilterGroups = queryResults
                    };

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                return(DataWrapper());
            }
        }
Exemplo n.º 2
0
        public DataWrapper GetTrimIncentiveDataByTrimIdZip([FromBody] string queryStr)
        {
            var query  = JsonConvert.DeserializeObject <TrimIncentivesQuery>(queryStr);
            var trimId = query.TrimId;
            var zip    = query.Zip;

            try
            {
                var superModelFilterGroups = VehicleSpecService.GetTrimIncentivesByTrimIdByZipAsync(int.Parse(trimId), zip).Result;
                if (superModelFilterGroups != null)
                {
                    var queryResults = superModelFilterGroups;

                    var response = new TrimIncentiveResponse
                    {
                        TrimIncentive = queryResults
                    };

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 3
0
        public DataWrapper GetSuperModelTrimFilterAttributesByMakeSuperModelByYear([FromBody] string queryStr)
        {
            var query          = JsonConvert.DeserializeObject <SuperModelFilterQueryByYear>(queryStr);
            var makeName       = query.MakeName;
            var superModelName = query.SuperModelName;
            var year           = query.Year;

            try
            {
                var superModelTrimFilterAttributes = VehicleSpecService.GetSuperModelTrimFilterAttributesByMakeSuperModelByYearAsync(makeName, superModelName, year).Result;
                if (superModelTrimFilterAttributes != null)
                {
                    var queryResults = superModelTrimFilterAttributes;

                    var response = new SuperModelTrimFilterAttributeResponse
                    {
                        SuperModelTrimFilterAttributes = queryResults
                    };

                    return(DataWrapper(response));
                }
                return(DataWrapper());
            }
            catch (Exception)
            {
                return(DataWrapper());
            }
        }
Exemplo n.º 4
0
        public DataWrapper GetCategoryTrimFilterAttributesByCategory([FromBody] string queryStr)
        {
            var query        = JsonConvert.DeserializeObject <CategoryFilterQuery>(queryStr);
            var categoryName = query.CategoryName;

            var categoryTranslator = UriTokenTranslators.GetCategoryTranslatorByName(categoryName);
            var categorySeoName    = categoryTranslator.SeoName;

            try
            {
                var categoryTrimFilterAttributes = VehicleSpecService.GetCategoryTrimFilterAttributesByCategoryAsync(categorySeoName).Result;
                if (categoryTrimFilterAttributes != null)
                {
                    var queryResults = categoryTrimFilterAttributes;

                    var response = new CategoryTrimFilterAttributeResponse
                    {
                        CategoryTrimFilterAttributes = queryResults
                    };

                    return(DataWrapper(response));
                }
                return(DataWrapper());
            }
            catch (Exception)
            {
                return(DataWrapper());
            }
        }
Exemplo n.º 5
0
        public DataWrapper GetCompareCarSuperModelByMakes(string makeSeoName)
        {
            var makeTranslator = UriTokenTranslators.GetMakeTranslatorBySeoName(makeSeoName);

            if (makeTranslator == null)
            {
                return(DataWrapper());
            }

            try
            {
                var compareSuperModelList = VehicleSpecService.GetNewSuperModelsByMakeAsync(makeSeoName).Result;
                if (compareSuperModelList != null)
                {
                    var response = compareSuperModelList.Select(t => new CompareSuperModels
                    {
                        Make    = t.Make,
                        Name    = t.Name,
                        SeoName = t.SeoName,
                    });

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 6
0
        public DataWrapper GetSuperModelFilterGroupDataByMakeSuperModel([FromBody] string queryStr)
        {
            var query          = JsonConvert.DeserializeObject <SuperModelFilterQuery>(queryStr);
            var makeName       = query.MakeName;
            var superModelName = query.SuperModelName;

            try
            {
                var superModelFilterGroups = VehicleSpecService.GetSuperModelFilterGroupDataByMakeSuperModelAsync(makeName, superModelName).Result;
                if (superModelFilterGroups != null)
                {
                    var queryResults = superModelFilterGroups;

                    var response = new SuperModelFilterGroupResponse
                    {
                        SuperModelFilterGroups = queryResults
                    };

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                return(DataWrapper());
            }
        }
Exemplo n.º 7
0
 public object GetMakes()
 {
     return(new
     {
         isKosher = true,
         makes = VehicleSpecService.GetMakes().Select(make => Mapper.Map <Dto.Make>(make))
     });
 }
Exemplo n.º 8
0
        public ActionResult Make(string makeSeoName)
        {
            const string assetsPrefix = "carsforsale.make";

            var makeTranslator = UriTokenTranslators.GetMakeTranslatorBySeoName(makeSeoName);

            if (makeTranslator == null)
            {
                return(HttpNotFound());
            }


            var metadata      = MetadataService.GetMetadataForPage(HttpContext);
            var vspModelsTask = VehicleSpecService.GetModelsByMakeAsync(makeSeoName);
            // availableModels => represents models we actually have inventory for
            var availableModelsTask = CarsForSaleService.GetModelsDomainByMakeIdAsync(makeTranslator.AbtMakeId);

            vspModelsTask.Wait();
            availableModelsTask.Wait();

            var vspModels       = vspModelsTask.Result;
            var availableModels = availableModelsTask.Result.Select(m => m.Description).ToList();

            var models = vspModels
                         .Where(m => availableModels.Contains(m.Name))
                         .Select(mo => new MakeViewModel.Dto.Model
            {
                MatchValue = String.Format("{0}~{1}", mo.AbtMakeId, mo.Name),
                Name       = mo.Name,
                SeoName    = mo.SeoName
            });

            var viewModel = new MakeViewModel(assetsPrefix, metadata)
            {
                InlineHeadScript = AssetService.GetInlineHeadScript(),
                InlineHeadStyles = AssetService.GetInlineHeadStyles(assetsPrefix),
                TrackMeta        = new TrackMeta(metadata)
                {
                    Make = makeTranslator.Name
                },
                AdvertMeta = new AdvertMeta(new
                {
                    make = makeTranslator.Name
                }),
                OfferMeta = new OfferMeta(new
                {
                    make = makeTranslator.Name
                }),
                Make = new MakeViewModel.Dto.Make
                {
                    Name    = makeTranslator.Name,
                    SeoName = makeTranslator.SeoName
                },
                Models = models
            };

            return(View("Make", viewModel));
        }
Exemplo n.º 9
0
 public object GetModelsByMakeId(int id)
 {
     return(new
     {
         isKosher = true,
         makeId = id,
         models = VehicleSpecService.GetModelsByMakeId(id).Select(model => Mapper.Map <Dto.Model>(model))
     });
 }
Exemplo n.º 10
0
        public DataWrapper GetCompareCarsDataByTrimIdList(string trimIdList)
        {
            try
            {
                if (trimIdList.Length < 1)
                {
                    return(DataWrapper());
                }

                var compareTrimData = VehicleSpecService.GetCompareCarsByTrimIdListAsync(trimIdList).Result;
                if (compareTrimData != null)
                {
                    //var queryResults = compareTrimData;

                    var response = compareTrimData.Select(t => new CompareTrim
                    {
                        Id                = t.Id,
                        CategoryId        = t.CategoryId,
                        Name              = t.Name,
                        SeoName           = t.SeoName,
                        Make              = t.Make,
                        MakeSeoName       = t.MakeSeoName,
                        SuperModel        = t.SuperModel,
                        SuperModelSeoName = t.SuperModelSeoName,
                        Year              = t.Year,
                        Model             = t.Model,
                        IsNew             = t.IsNew,
                        Msrp              = String.Format("${0:0,0}", Convert.ToDouble(t.Msrp)),
                        Invoice           = String.Format("${0:0,0}", Convert.ToDouble(t.Invoice)),
                        CityMpg           = t.CityMpg,
                        HighwayMpg        = t.HighwayMpg,
                        EngineType        = t.EngineType,
                        EngineSize        = t.EngineSize,
                        HorsePower        = t.HorsePower,
                        Specifications    = t.Specifications,
                        Images            = ImageMetaService.GetImagesByTrimIdAsync(t.Id).Result
                                            .Select(im => new Image
                        {
                            Small  = String.Format("{0}_320x.png", im.UrlPrefix),
                            Medium = String.Format("{0}_640x.png", im.UrlPrefix),
                            Large  = String.Format("{0}_1024x.png", im.UrlPrefix)
                        })
                    });

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 11
0
        public DataWrapper GetSimilarVehiclesByPrice([FromBody] string queryStr)
        {
            var query = JsonConvert.DeserializeObject <SimilarVehiclePriceQuery>(queryStr);
            var price = query.Price;

            try
            {
                var resultTrimList = new List <TrimListItem>();

                var trimslist = VehicleSpecService.GetSimilarTrimsByPriceAsync(price).Result;

                if (trimslist != null)
                {
                    foreach (var t in trimslist)
                    {
                        int    msrp;
                        string msrpVar;

                        msrpVar = (t.Msrp.IsNotNullOrEmpty() && Int32.TryParse(t.Msrp, out msrp))
              ? String.Format("{0:C}", msrp).Replace(".00", "")
              : String.Empty;

                        resultTrimList.Add(new TrimListItem()
                        {
                            Id              = t.Id,
                            Make            = t.Make,
                            MakeSeo         = t.MakeSeoName,
                            SuperModelSeo   = t.SuperModel,
                            Model           = t.Model,
                            Year            = t.Year.ToString(),
                            StartingMsrp    = msrpVar,
                            FullDisplayName = t.FullDisplayName,
                            TrimSeoName     = t.SeoName,
                            Name            = t.Name,
                            ImagePath       = String.Format("{0}_320x.png", t.ImagePath)
                        });
                    }
                    return(DataWrapper(resultTrimList));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 12
0
        public DataWrapper GetTrimsByMakeBySuperModelByYear([FromBody] string queryStr)
        {
            var query      = JsonConvert.DeserializeObject <TrimListQuery>(queryStr);
            var make       = query.Make;
            var supermodel = query.Supermodel;
            var year       = query.Year;
            var supertrim  = query.Supertrim;

            try
            {
                var resultTrimList = new List <TrimListItem>();

                var trimslist = VehicleSpecService.GetTrimsByMakeBySuperModelByYearAsync(make, supermodel, year).Result
                                .Where(t => t.SuperTrim == supertrim)
                                .OrderBy(t => t.Msrp).ThenBy(t => t.FullDisplayName);

                if (trimslist != null)
                {
                    foreach (var t in trimslist)
                    {
                        int    msrp;
                        string msrpVar;

                        msrpVar = (t.Msrp.IsNotNullOrEmpty() && Int32.TryParse(t.Msrp, out msrp))
              ? String.Format("{0:C}", msrp).Replace(".00", "")
              : String.Empty;

                        resultTrimList.Add(new TrimListItem()
                        {
                            MakeSeo         = make,
                            SuperModelSeo   = supermodel,
                            Year            = year.ToString(),
                            StartingMsrp    = msrpVar,
                            FullDisplayName = t.FullDisplayName,
                            TrimSeoName     = t.SeoName
                        });
                    }
                    return(DataWrapper(resultTrimList));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 13
0
        public DataWrapper GetViewedRecentlyByTrimIdList(string trimIdList)
        {
            try
            {
                if (trimIdList.Length < 1)
                {
                    return(DataWrapper());
                }

                var compareTrimData = VehicleSpecService.GetCompareCarsByTrimIdListAsync(trimIdList).Result;
                if (compareTrimData != null)
                {
                    //var queryResults = compareTrimData;

                    var response = compareTrimData.Select(t => new ViewedRecentlyTrim
                    {
                        Id                = t.Id,
                        Name              = t.Name,
                        SeoName           = t.SeoName,
                        Make              = t.Make,
                        MakeSeoName       = t.MakeSeoName,
                        SuperModel        = t.SuperModel,
                        SuperModelSeoName = t.SuperModelSeoName,
                        Year              = t.Year,
                        Model             = t.Model,
                        IsNew             = t.IsNew,
                        Images            = ImageMetaService.GetImagesByTrimIdAsync(t.Id).Result
                                            .Select(im => new Image
                        {
                            Small  = String.Format("{0}_320x.png", im.UrlPrefix),
                            Medium = String.Format("{0}_640x.png", im.UrlPrefix),
                            Large  = String.Format("{0}_1024x.png", im.UrlPrefix)
                        })
                    });

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 14
0
        public ActionResult Index()
        {
            const string assetsPrefix = "carsforsale.index";
            const int    numberOfMakesToInitiallyShow = 36;

            var metadata = MetadataService.GetMetadataForPage(HttpContext);

            var makesTask = VehicleSpecService.GetAllMakesAsync();

            var topMakeNames = CarsForSaleService.GetTopMakesWithInventoryCount(numberOfMakesToInitiallyShow);
            var categories   = CarsForSaleService.FilterDomains.Categories;

            makesTask.Wait();
            var makes = makesTask.Result;

            makes = makes.Where(m => !CarsForSaleService.MakesBlackList.Contains(m.Name)).ToList();


            var viewModel = new IndexViewModel(assetsPrefix, metadata)
            {
                InlineHeadScript = AssetService.GetInlineHeadScript(),
                InlineHeadStyles = AssetService.GetInlineHeadStyles(assetsPrefix),
                AdvertMeta       = new AdvertMeta(),
                TrackMeta        = new TrackMeta(metadata),
                Makes            = makes.Select(ma => new IndexViewModel.Dto.Make
                {
                    CanShow    = topMakeNames.ContainsKey(ma.Name),
                    MatchValue = ma.AbtMakeId.ToString(CultureInfo.InvariantCulture),
                    Name       = ma.Name,
                    SeoName    = ma.SeoName
                }),
                Categories = categories.Select(cat => new IndexViewModel.Dto.Category
                {
                    MatchValue = cat.MatchValue,
                    Name       = cat.Description
                })
            };

            return(View("Index", viewModel));
        }
Exemplo n.º 15
0
        public DataWrapper GetCompareCarTrimsByMakeBySuperModel(string makeSeoName, string superModelSeoName)
        {
            var makeTranslator       = UriTokenTranslators.GetMakeTranslatorBySeoName(makeSeoName);
            var superModelTranslator = UriTokenTranslators.GetSuperModelTranslatorBySeoName(superModelSeoName);

            if (makeTranslator == null || superModelTranslator == null)
            {
                return(DataWrapper());
            }

            try
            {
                var compareTrimList = VehicleSpecService.GetNewTrimsByMakeBySuperModelAsync(makeSeoName, superModelSeoName).Result;
                if (compareTrimList != null)
                {
                    var response = compareTrimList
                                   .OrderByDescending(t => t.Year)
                                   .ThenBy(t => t.Make)
                                   .ThenBy(t => t.Model)
                                   .ThenBy(t => t.Name)
                                   .Select(t => new CompareListTrim
                    {
                        Name    = t.Name,
                        SeoName = t.SeoName,
                        Year    = t.Year,
                        Id      = t.Id,
                        Msrp    = t.Msrp
                    });

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 16
0
        public ActionResult Index()
        {
            var refiSourceIds = JsonConvert.SerializeObject(
                LeadDataService.RefinanceSources
                .Select(s => new { id = s.SourceId }).ToList());

            var model = new Index
            {
                RedirectUrl   = RedirectUrl,
                RedirectTtlms = RedirectTtlms,
                NoPlacementCopyTextDuplicate = NoPlacementCopyTextDuplicate,
                PageMeta = PageMeta,
                PurchaseModePageSequence  = PurchaseModePageSequence,
                RefinanceModePageSequence = RefinanceModePageSequence,
                NoQualifyModePageSequence = NoQualifyModePageSequence,
                RefinanceSourceIds        = refiSourceIds,
                Makes = JsonConvert.SerializeObject(VehicleSpecService
                                                    .GetMakes().Where(m => m.IsActive).Select(m => new { value = m.Id, label = m.Name }).ToList())
            };

            return(View("Index", model));
        }
Exemplo n.º 17
0
        //[Route("status-500", Name = "HttpError_Status500"), HttpGet]
        public ActionResult Status500()
        {
            const string assetsPrefix = "httperror.status500";

            var metadata       = MetadataService.GetMetadataForPage(HttpContext);
            var makesTask      = VehicleSpecService.GetAllActiveMakesAsync();
            var categoriesTask = VehicleSpecService.GetAllCategoriesAsync();

            makesTask.Wait();
            categoriesTask.Wait();
            var makes      = makesTask.Result;
            var categories = categoriesTask.Result;

            var viewModel = new ErrorViewModel(assetsPrefix, metadata)
            {
                InlineHeadScript = AssetService.GetInlineHeadScript(),
                InlineHeadStyles = AssetService.GetInlineHeadStyles(assetsPrefix),
                Makes            = makes,
                Categories       = categories
            };

            return(View(@"~\Views\HttpError\Status500.cshtml", viewModel));
        }
Exemplo n.º 18
0
        public DataWrapper GetCompareCarMakes()
        {
            try
            {
                var compareMakeList = VehicleSpecService.GetAllActiveMakesAsync().Result;
                if (compareMakeList != null)
                {
                    var response = compareMakeList.Select(t => new CompareMakes
                    {
                        Name    = t.Name,
                        SeoName = t.SeoName,
                    });

                    return(DataWrapper(response));
                }

                return(DataWrapper());
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Exemplo n.º 19
0
        private static void CacheAllSiteMapData()
        {
            try
            {
                var pagesBySectionDict = new Dictionary <string, IEnumerable <Page> >();
                var lastModified       = DateTime.Now.ToString("yyyy-MM-dd");

                #region **! Here, we are caching all the sitemap sections for the sitemap-index page.

                _sections = SectionNames
                            .Select(sectionName => new Section
                {
                    DomainAndPath = String.Format("{0}/sitemap/{1}", Host, sectionName),
                    LastModified  = lastModified
                });

                #endregion


                #region **! Here, we are caching all the pages for each sitemap section.

                #region Cache all pages for the *general* sitemap section.
                const string generalSection = "general";

                pagesBySectionDict.Add(generalSection, new List <Page>
                {
                    new Page
                    {
                        DomainAndPath   = Host,
                        LastModified    = lastModified,
                        ChangeFrequency = ChangeFrequency.Weekly,
                        Priority        = Priority.Top
                    },
                    new Page
                    {
                        DomainAndPath   = String.Format("{0}/{1}", Host, "cars-for-sale"),
                        LastModified    = lastModified,
                        ChangeFrequency = ChangeFrequency.Weekly,
                        Priority        = Priority.Medium
                    }
                });

                #endregion


                #region Cache all pages for the *car-research* sitemap section.

                // NOTE: We are only going after all the *NEW* cars in this section.
                const string researchSection = "car-research";

                // landing page
                var researchPages = new List <Page>
                {
                    new Page
                    {
                        DomainAndPath   = String.Format("{0}/{1}", Host, researchSection),
                        LastModified    = lastModified,
                        ChangeFrequency = ChangeFrequency.Weekly,
                        Priority        = Priority.Top
                    }
                };

                // make pages
                var researchMakes = UriTokenTranslators.GetAllMakeTranslators()
                                    .Where(make => make.IsActive)
                                    .Select(make => new Dto.CarResearchUrl
                {
                    Make = make.SeoName
                }).ToList().OrderBy(s => s.Make);

                researchPages.AddRange(researchMakes
                                       .Select(carResearchUrl => new Page
                {
                    DomainAndPath   = String.Format("{0}/{1}", Host, carResearchUrl.Make),
                    LastModified    = lastModified,
                    ChangeFrequency = ChangeFrequency.Weekly,
                    Priority        = Priority.Medium
                }).ToList());


                // make/super-model pages
                var researchMakeSuperModels = VehicleSpecService.GetAllNewSuperModels()
                                              .Select(superModel => new Dto.CarResearchUrl
                {
                    Make       = UriTokenTranslators.GetMakeTranslatorByName(superModel.Make).SeoName,
                    SuperModel = superModel.SeoName
                }).ToList().OrderBy(s => s.Make).ThenBy(s => s.SuperModel);

                researchPages.AddRange(researchMakeSuperModels
                                       .Select(carResearchUrl => new Page
                {
                    DomainAndPath   = String.Format("{0}/{1}/{2}", Host, carResearchUrl.Make, carResearchUrl.SuperModel),
                    LastModified    = lastModified,
                    ChangeFrequency = ChangeFrequency.Weekly,
                    Priority        = Priority.Medium
                }).ToList());


                // make/super-model/year pages
                var makeSuperModelYears =
                    (from superModel in VehicleSpecService.GetAllNewSuperModels()
                     from year in superModel.Years
                     where year.IsNew
                     select new Dto.CarResearchUrl
                {
                    Make = UriTokenTranslators.GetMakeTranslatorByName(superModel.Make).SeoName,
                    SuperModel = superModel.SeoName,
                    Year = year.Number
                }).ToList().OrderBy(s => s.Make).ThenBy(s => s.SuperModel).ThenBy(s => s.Year);

                researchPages.AddRange(makeSuperModelYears
                                       .Select(carResearchUrl => new Page
                {
                    DomainAndPath =
                        String.Format("{0}/{1}/{2}/{3}",
                                      Host, carResearchUrl.Make, carResearchUrl.SuperModel, carResearchUrl.Year),
                    LastModified    = lastModified,
                    ChangeFrequency = ChangeFrequency.Weekly,
                    Priority        = Priority.Medium
                }).ToList());


                // make/super-model/year/trim pages
                var makeSuperModelYearTrims =
                    (from msmy in makeSuperModelYears
                     from trim in VehicleSpecService.GetTrimsByMakeBySuperModelByYear(msmy.Make, msmy.SuperModel, msmy.Year)
                     select new Dto.CarResearchUrl
                {
                    Make = msmy.Make,
                    SuperModel = msmy.SuperModel,
                    Year = msmy.Year,
                    Trim = trim.CanonicalSeoName
                }).ToList().OrderBy(s => s.Make).ThenBy(s => s.SuperModel).ThenBy(s => s.Trim).ThenBy(s => s.Year);

                var makeSuperModelYearTrimsDistinct = makeSuperModelYearTrims.GroupBy(x => x.Trim).Select(g => g.First());

                researchPages.AddRange(makeSuperModelYearTrimsDistinct
                                       .Select(carResearchUrl => new Page
                {
                    DomainAndPath =
                        String.Format("{0}/{1}/{2}/{3}/{4}",
                                      Host, carResearchUrl.Make, carResearchUrl.SuperModel, carResearchUrl.Year, carResearchUrl.Trim),
                    LastModified    = lastModified,
                    ChangeFrequency = ChangeFrequency.Weekly,
                    Priority        = Priority.Medium
                }).ToList());


                // make/super-model/year/trim/section pages
                var trimSectionNames = new List <string>
                {
                    "specifications",
                    "color",
                    "warranty",
                    "pictures-videos",
                    "incentives",
                    "safety"
                };

                var makeSuperModelYearTrimSections =
                    (from msmyt in makeSuperModelYearTrimsDistinct
                     from sectionName in trimSectionNames
                     select new Dto.CarResearchUrl
                {
                    Make = msmyt.Make,
                    SuperModel = msmyt.SuperModel,
                    Year = msmyt.Year,
                    Trim = msmyt.Trim,
                    Section = sectionName
                }).ToList().OrderBy(s => s.Make).ThenBy(s => s.SuperModel).ThenBy(s => s.Trim).ThenBy(s => s.Year).ThenBy(s => s.Section);

                researchPages.AddRange(makeSuperModelYearTrimSections
                                       .Select(carResearchUrl => new Page
                {
                    DomainAndPath =
                        String.Format("{0}/{1}/{2}/{3}/{4}/{5}",
                                      Host, carResearchUrl.Make, carResearchUrl.SuperModel, carResearchUrl.Year, carResearchUrl.Trim, carResearchUrl.Section),
                    LastModified    = lastModified,
                    ChangeFrequency = ChangeFrequency.Weekly,
                    Priority        = Priority.Low
                }).ToList());


                // Add them all here!
                pagesBySectionDict.Add(researchSection, researchPages);

                #endregion


                #region Cache all pages for the *buying-tools* sitemap section.
                const string toolsSection = "buying-tools";

                var toolNames = new List <string>
                {
                    "tools/car-comparison",
                    "tools/calculators",
                    "tools/calculators/payment-calculator",
                    "tools/calculators/affordability-calculator",
                    "tools/calculators/fuel-savings-calculator",
                    "tools/calculators/lease-vs-buy-calculator",
                    "tools/calculators/early-payoff-calculator",
                    "tools/calculators/rebate-vs-financing-calculator",
                    "tools/used-car-values"
                };

                var toolPages = new List <Page>
                {
                    new Page
                    {
                        DomainAndPath   = String.Format("{0}/{1}", Host, "tools"),
                        LastModified    = lastModified,
                        ChangeFrequency = ChangeFrequency.Monthly,
                        Priority        = Priority.Top
                    }
                };

                toolPages.AddRange(toolNames
                                   .Select(toolName => new Page
                {
                    DomainAndPath   = String.Format("{0}/{1}", Host, toolName),
                    LastModified    = lastModified,
                    ChangeFrequency = ChangeFrequency.Monthly,
                    Priority        = Priority.Medium
                }));


                // Add them all here!
                pagesBySectionDict.Add(toolsSection, toolPages);

                #endregion


                #region Cache all pages for the *content* sitemap section.

                const string contentSection = "content";

                var contentPages = new List <Page>
                {
                    new Page
                    {
                        DomainAndPath   = String.Format("{0}/{1}", Host, "buying-guides"),
                        LastModified    = lastModified,
                        ChangeFrequency = ChangeFrequency.Weekly,
                        Priority        = Priority.Top
                    },
                    new Page
                    {
                        DomainAndPath   = String.Format("{0}/{1}", Host, "finance"),
                        LastModified    = lastModified,
                        ChangeFrequency = ChangeFrequency.Weekly,
                        Priority        = Priority.Medium
                    }
                };

                // article urls
                var articleUrls = VehicleContentService.GetAllArticleUrlsForSitemap();

                contentPages.AddRange(articleUrls
                                      .Select(articleUrl => new Page
                {
                    DomainAndPath   = String.Format("{0}{1}", Host, articleUrl.TrimEnd(new [] { '/' })),
                    LastModified    = lastModified,
                    ChangeFrequency = ChangeFrequency.Weekly,
                    Priority        = Priority.Low
                }).ToList());

                pagesBySectionDict.Add(contentSection, contentPages);

                #endregion

                lock (Mutex)
                {
                    _pagesBySectionDict = pagesBySectionDict;
                }

                #endregion
            }
            catch (Exception ex)
            {
                Log.Fatal(String.Format(
                              "The SitemapService Failed during the caching process. It's likely an SeoName problem exists in the data./r/n{0}",
                              ex.Message));
            }
        }