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> SearchByVehicleId(string vehicleId)
        {
            var applyFilters = new VehicleSearchFilters()
            {
                VehicleId = vehicleId,
            };
            var result = await _vehicleSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                 new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "regionName",
                    "vehicleTypeName",
                    "vehicleTypeGroupName",
                    "makeName",
                    "modelName,count:20",
                    "subModelName,count:20"
                },
                RecordCount = 1000
            });

            var vehicleSearchViewModel = _vehicleSearchViewModelMapper.Map(result);

            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);
        }
        public void Should_Return_Azure_Filter_String()
        {
            var vehicleSearchFilter = new VehicleSearchFilters()
            {
                StartYear = 2005,
                EndYear   = 2010,
                Makes     = new string[]
                {
                    "Toyota",
                    "Honda"
                },
                Models = new[]
                {
                    "Camry",
                    "Civic"
                }
            };

            var result = vehicleSearchFilter.ToAzureSearchFilter();

            Assert.True(result ==
                        "(((year ge '2005' and year ge '2010') and (makeName eq 'Toyota' or makeName eq 'Honda')) and (modelName eq 'Camry' or modelName eq 'Civic'))");
        }