private async Task <string[]> RefreshSubModelsFacet(VehicleSearchInputModel vehicleSearchInputModel)
        {
            var applyFilters = new VehicleSearchFilters()
            {
                StartYear         = Convert.ToInt32(vehicleSearchInputModel.StartYear),
                EndYear           = Convert.ToInt32(vehicleSearchInputModel.EndYear),
                Makes             = vehicleSearchInputModel.Makes,
                Models            = vehicleSearchInputModel.Models,
                VehicleTypes      = vehicleSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleSearchInputModel.VehicleTypeGroups,
                Regions           = vehicleSearchInputModel.Regions
            };

            var result = await _vehicleSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                 new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "subModelName,count:1000",
                },
                RecordCount = 0
            });

            var vehicleSearchViewModel = _vehicleSearchViewModelMapper.Map(result);

            return(vehicleSearchViewModel.Facets.SubModels);
        }
        public async Task <VehicleSearchViewModel> RefreshFacets(VehicleSearchInputModel vehicleSearchInputModel)
        {
            var vehicleSearchViewModel = new VehicleSearchViewModel
            {
                Facets = new VehicleSearchFacets
                {
                    Regions           = await RefreshRegionFacet(vehicleSearchInputModel),
                    VehicleTypeGroups = await RefreshVehicleTypeGroupFacet(vehicleSearchInputModel),
                    VehicleTypes      = await RefreshVehicleTypeFacet(vehicleSearchInputModel),
                    Years             = await RefreshYearFacet(vehicleSearchInputModel),
                    Makes             = await RefreshMakesFacet(vehicleSearchInputModel),
                    Models            = await RefreshModelsFacet(vehicleSearchInputModel),
                    SubModels         = await RefreshSubModelsFacet(vehicleSearchInputModel)
                }
            };

            return(vehicleSearchViewModel);
        }
        private async Task <string[]> RefreshRegionFacet(VehicleSearchInputModel vehicleSearchInputModel)
        {
            var applyFilters = new VehicleSearchFilters()
            {
            };

            var result = await _vehicleSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                 new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "regionName,count:1000",
                },
                RecordCount = 0
            });

            var vehicleSearchViewModel = _vehicleSearchViewModelMapper.Map(result);

            return(vehicleSearchViewModel.Facets.Regions);
        }
        public async Task <VehicleSearchViewModel> Search(VehicleSearchInputModel vehicleSearchInputModel)
        {
            var applyFilters = new VehicleSearchFilters()
            {
                StartYear         = Convert.ToInt32(vehicleSearchInputModel.StartYear),
                EndYear           = Convert.ToInt32(vehicleSearchInputModel.EndYear),
                Makes             = vehicleSearchInputModel.Makes,
                Models            = vehicleSearchInputModel.Models,
                SubModels         = vehicleSearchInputModel.SubModels,
                VehicleTypes      = vehicleSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleSearchInputModel.VehicleTypeGroups,
                Regions           = vehicleSearchInputModel.Regions
            };
            var result = await _vehicleSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                 new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "regionName,count:1000",
                    "vehicleTypeName,count:1000",
                    "vehicleTypeGroupName,count:1000",
                    "makeName,count:1000",
                    "modelName,count:1000",
                    "subModelName,count:1000"
                },
                RecordCount      = 1000,
                ReturnTotalCount = true,
                //NOTE: default sorting by base id desc is done in client side
                //OrderBy = new List<string>()
                //{
                //    "baseVehicleId desc",
                //}
            });

            var vehicleSearchViewModel = _vehicleSearchViewModelMapper.Map(result);

            return(vehicleSearchViewModel);
        }