private async Task <string[]> RefreshSubModelsFacet(
            VehicleToBodyStyleConfigSearchInputModel vehicleToBodyStyleConfigSearchInputModel)
        {
            var applyFilters = new VehicleToBodyStyleConfigSearchFilters()
            {
                BodyStyleConfigId = vehicleToBodyStyleConfigSearchInputModel.BodyStyleConfigId,
                Regions           = vehicleToBodyStyleConfigSearchInputModel.Regions,
                VehicleTypes      = vehicleToBodyStyleConfigSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleToBodyStyleConfigSearchInputModel.VehicleTypeGroups,
                StartYear         = Convert.ToInt32(vehicleToBodyStyleConfigSearchInputModel.StartYear),
                EndYear           = Convert.ToInt32(vehicleToBodyStyleConfigSearchInputModel.EndYear),
                BodyNumDoors      = vehicleToBodyStyleConfigSearchInputModel.BodyNumDoors,
                BodyTypes         = vehicleToBodyStyleConfigSearchInputModel.BodyTypes,
                Makes             = vehicleToBodyStyleConfigSearchInputModel.Makes,
                Models            = vehicleToBodyStyleConfigSearchInputModel.Models,
            };
            var result =
                await _vehicleToBodyStyleConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                         new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "subModelName,count:1000",
                },
                RecordCount = 0
            });

            var vehicleToBodyStyleConfigSearchViewModel = _vehicleToBodyStyleConfigSearchViewModelMapper.Map(result);

            return(vehicleToBodyStyleConfigSearchViewModel.Facets.SubModels);
        }
        public async Task <VehicleToBodyStyleConfigSearchViewModel> SearchByBodyStyleConfigId(int bodyStyleConfigId)
        {
            var applyFilters = new VehicleToBodyStyleConfigSearchFilters()
            {
                BodyStyleConfigId = bodyStyleConfigId,
            };
            var result =
                await _vehicleToBodyStyleConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                         new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    // vehicle
                    "makeName,count:1000",
                    "modelName,count:1000",
                    "subModelName,count:1000",
                    "regionName,count:1000",
                    // body
                    "bodyStyleConfigId",
                    "bodyNumDoors,count:1000",
                    "bodyTypeName,count:1000",
                    // others
                    "vehicleTypeName,count:1000",
                    "vehicleTypeGroupName,count:1000"
                },
                RecordCount = 1000
            });

            var bodyStyleConfigSearchViewModel = _vehicleToBodyStyleConfigSearchViewModelMapper.Map(result);

            return(bodyStyleConfigSearchViewModel);
        }
        public async Task <VehicleToBodyStyleConfigSearchViewModel> Search(
            VehicleToBodyStyleConfigSearchInputModel vehicleToBodyStyleConfigSearchInputModel)
        {
            var applyFilters = new VehicleToBodyStyleConfigSearchFilters()
            {
                BodyStyleConfigId = vehicleToBodyStyleConfigSearchInputModel.BodyStyleConfigId,
                // vehicle
                Makes     = vehicleToBodyStyleConfigSearchInputModel.Makes,
                Models    = vehicleToBodyStyleConfigSearchInputModel.Models,
                SubModels = vehicleToBodyStyleConfigSearchInputModel.SubModels,
                StartYear = Convert.ToInt32(vehicleToBodyStyleConfigSearchInputModel.StartYear),
                EndYear   = Convert.ToInt32(vehicleToBodyStyleConfigSearchInputModel.EndYear),
                Regions   = vehicleToBodyStyleConfigSearchInputModel.Regions,
                // body
                BodyNumDoors = vehicleToBodyStyleConfigSearchInputModel.BodyNumDoors,
                BodyTypes    = vehicleToBodyStyleConfigSearchInputModel.BodyTypes,
                // others
                VehicleTypes      = vehicleToBodyStyleConfigSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleToBodyStyleConfigSearchInputModel.VehicleTypeGroups
            };

            var result =
                await _vehicleToBodyStyleConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                         new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    // vehicle
                    "makeName,count:1000",
                    "modelName,count:1000",
                    "subModelName,count:1000",
                    "regionName,count:1000",
                    // body
                    "bodyNumDoors,count:1000",
                    "bodyTypeName,count:1000",
                    // others
                    "vehicleTypeName,count:1000",
                    "vehicleTypeGroupName,count:1000",
                },
                RecordCount      = 1000,
                ReturnTotalCount = true
            });

            var viewModel = _vehicleToBodyStyleConfigSearchViewModelMapper.Map(result);

            return(viewModel);
        }
        public async Task <List <VehicleToBodyStyleConfigViewModel> > Search(List <string> vehicleIdArray)
        {
            List <VehicleToBodyStyleConfigViewModel> vehicleToBodyStyleConfigs = null;

            if (vehicleIdArray != null && vehicleIdArray.Count > 0)
            {
                var applyFilters = new VehicleToBodyStyleConfigSearchFilters()
                {
                    VehicleIds = vehicleIdArray.Select(item => Convert.ToInt32(item)).ToArray()
                };

                var result =
                    await _vehicleToBodyStyleConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                             new SearchOptions
                {
                    RecordCount = 1000
                });

                vehicleToBodyStyleConfigs = _vehicleToBodyStyleConfigViewModelMapper.Map(result);
            }
            return(vehicleToBodyStyleConfigs);
        }
        private async Task <string[]> RefreshRegionFacet(
            VehicleToBodyStyleConfigSearchInputModel vehicleToBodyStyleConfigSearchInputModel)
        {
            var applyFilters = new VehicleToBodyStyleConfigSearchFilters()
            {
                BodyStyleConfigId = vehicleToBodyStyleConfigSearchInputModel.BodyStyleConfigId,
                BodyNumDoors      = vehicleToBodyStyleConfigSearchInputModel.BodyNumDoors,
                BodyTypes         = vehicleToBodyStyleConfigSearchInputModel.BodyTypes,
            };
            var result =
                await _vehicleToBodyStyleConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                         new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "regionName,count:1000",
                },
                RecordCount = 0
            });

            var vehicleToBodyStyleConfigSearchViewModel = _vehicleToBodyStyleConfigSearchViewModelMapper.Map(result);

            return(vehicleToBodyStyleConfigSearchViewModel.Facets.Regions);
        }
        public async Task <List <VehicleToBodyStyleConfigViewModel> > GetAssociations(VehicleToBodyStyleConfigSearchInputModel vehicleToBodyStyleConfigSearchInputModel)
        {
            List <VehicleToBodyStyleConfigViewModel> vehicleToBodyStyleConfigs = new List <VehicleToBodyStyleConfigViewModel>();

            var applyFilters = new VehicleToBodyStyleConfigSearchFilters()
            {
                BodyStyleConfigId = vehicleToBodyStyleConfigSearchInputModel.BodyStyleConfigId,
                StartYear         = Convert.ToInt32(vehicleToBodyStyleConfigSearchInputModel.StartYear),
                EndYear           = Convert.ToInt32(vehicleToBodyStyleConfigSearchInputModel.EndYear),
                Makes             = vehicleToBodyStyleConfigSearchInputModel.Makes,
                Models            = vehicleToBodyStyleConfigSearchInputModel.Models,
                SubModels         = vehicleToBodyStyleConfigSearchInputModel.SubModels,
                VehicleTypes      = vehicleToBodyStyleConfigSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleToBodyStyleConfigSearchInputModel.VehicleTypeGroups,
                Regions           = vehicleToBodyStyleConfigSearchInputModel.Regions,
            };

            bool isEndReached = false;
            int  pageNumber   = 1;

            do
            {
                var result = await _vehicleToBodyStyleConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                                      new SearchOptions()
                {
                    RecordCount = 1000, PageNumber = pageNumber
                });

                if (result != null && result.Documents != null && result.Documents.Any())
                {
                    vehicleToBodyStyleConfigs.AddRange(_vehicleToBodyStyleConfigViewModelMapper.Map(result));

                    pageNumber++;
                }
                else
                {
                    isEndReached = true;
                }
            } while (!isEndReached);

            return(vehicleToBodyStyleConfigs);
        }