private async Task <string[]> RefreshSubModelsFacet(VehicleToBrakeConfigSearchInputModel vehicleToBrakeConfigSearchInputModel)
        {
            var applyFilters = new VehicleToBrakeConfigSearchFilters()
            {
                BrakeConfigId     = vehicleToBrakeConfigSearchInputModel.BrakeConfigId,
                StartYear         = Convert.ToInt32(vehicleToBrakeConfigSearchInputModel.StartYear),
                EndYear           = Convert.ToInt32(vehicleToBrakeConfigSearchInputModel.EndYear),
                Makes             = vehicleToBrakeConfigSearchInputModel.Makes,
                Models            = vehicleToBrakeConfigSearchInputModel.Models,
                VehicleTypes      = vehicleToBrakeConfigSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleToBrakeConfigSearchInputModel.VehicleTypeGroups,
                Regions           = vehicleToBrakeConfigSearchInputModel.Regions,
                FrontBrakeTypes   = vehicleToBrakeConfigSearchInputModel.FrontBrakeTypes,
                RearBrakeTypes    = vehicleToBrakeConfigSearchInputModel.RearBrakeTypes,
                BrakeAbs          = vehicleToBrakeConfigSearchInputModel.BrakeAbs,
                BrakeSystem       = vehicleToBrakeConfigSearchInputModel.BrakeSystems,
            };

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

            var vehicleToBrakeConfigSearchViewModel = _vehicleToBrakeConfigSearchViewModelMapper.Map(result);

            return(vehicleToBrakeConfigSearchViewModel.Facets.SubModels);
        }
        private async Task <string[]> RefreshRegionFacet(VehicleToBrakeConfigSearchInputModel vehicleToBrakeConfigSearchInputModel)
        {
            var applyFilters = new VehicleToBrakeConfigSearchFilters()
            {
                BrakeConfigId   = vehicleToBrakeConfigSearchInputModel.BrakeConfigId,
                FrontBrakeTypes = vehicleToBrakeConfigSearchInputModel.FrontBrakeTypes,
                RearBrakeTypes  = vehicleToBrakeConfigSearchInputModel.RearBrakeTypes,
                BrakeAbs        = vehicleToBrakeConfigSearchInputModel.BrakeAbs,
                BrakeSystem     = vehicleToBrakeConfigSearchInputModel.BrakeSystems,
            };

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

            var vehicleToBrakeConfigSearchViewModel = _vehicleToBrakeConfigSearchViewModelMapper.Map(result);

            return(vehicleToBrakeConfigSearchViewModel.Facets.Regions);
        }
        public async Task <VehicleToBrakeConfigSearchViewModel> SearchByBrakeConfigId(int brakeConfigId)
        {
            var applyFilters = new VehicleToBrakeConfigSearchFilters()
            {
                BrakeConfigId = brakeConfigId,
            };
            var result = await _vehicleToBrakeConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                              new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "frontBrakeTypeName",
                    "rearBrakeTypeName",
                    "brakeABSName",
                    "brakeSystemName",
                    "regionName",
                    "vehicleTypeName",
                    "vehicleTypeGroupName",
                    "makeName",
                    "modelName",
                    "subModelName",
                    "brakeConfigId"
                },
                RecordCount      = 1000,
                ReturnTotalCount = true,
            });

            var brakeConfigSearchViewModel = _vehicleToBrakeConfigSearchViewModelMapper.Map(result);

            return(brakeConfigSearchViewModel);
        }
        public async Task <VehicleToBrakeConfigSearchViewModel> Search(VehicleToBrakeConfigSearchInputModel vehicleToBrakeConfigSearchInputModel)
        {
            var applyFilters = new VehicleToBrakeConfigSearchFilters()
            {
                BrakeConfigId     = vehicleToBrakeConfigSearchInputModel.BrakeConfigId,
                StartYear         = Convert.ToInt32(vehicleToBrakeConfigSearchInputModel.StartYear),
                EndYear           = Convert.ToInt32(vehicleToBrakeConfigSearchInputModel.EndYear),
                Makes             = vehicleToBrakeConfigSearchInputModel.Makes,
                Models            = vehicleToBrakeConfigSearchInputModel.Models,
                SubModels         = vehicleToBrakeConfigSearchInputModel.SubModels,
                VehicleTypes      = vehicleToBrakeConfigSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleToBrakeConfigSearchInputModel.VehicleTypeGroups,
                Regions           = vehicleToBrakeConfigSearchInputModel.Regions,
                FrontBrakeTypes   = vehicleToBrakeConfigSearchInputModel.FrontBrakeTypes,
                RearBrakeTypes    = vehicleToBrakeConfigSearchInputModel.RearBrakeTypes,
                BrakeAbs          = vehicleToBrakeConfigSearchInputModel.BrakeAbs,
                BrakeSystem       = vehicleToBrakeConfigSearchInputModel.BrakeSystems
            };

            var result = await _vehicleToBrakeConfigSearchService.SearchAsync("", applyFilters.ToAzureSearchFilter(),
                                                                              new SearchOptions
            {
                FacetsToInclude = new List <string>
                {
                    "frontBrakeTypeName,count:1000",
                    "rearBrakeTypeName,count:1000",
                    "brakeABSName,count:1000",
                    "brakeSystemName,count:1000",
                    "regionName,count:1000",
                    "vehicleTypeName,count:1000",
                    "vehicleTypeGroupName,count:1000",
                    "makeName,count:1000",
                    "modelName,count:1000",
                    "subModelName,count:1000",
                },
                RecordCount      = 1000,
                ReturnTotalCount = true,
            });

            var viewModel = _vehicleToBrakeConfigSearchViewModelMapper.Map(result);

            return(viewModel);
        }
        public async Task <List <VehicleToBrakeConfigViewModel> > GetAssociations(VehicleToBrakeConfigSearchInputModel vehicleToBrakeConfigSearchInputModel)
        {
            List <VehicleToBrakeConfigViewModel> vehicleToBrakeConfigs = new List <VehicleToBrakeConfigViewModel>();

            var applyFilters = new VehicleToBrakeConfigSearchFilters()
            {
                BrakeConfigId     = vehicleToBrakeConfigSearchInputModel.BrakeConfigId,
                StartYear         = Convert.ToInt32(vehicleToBrakeConfigSearchInputModel.StartYear),
                EndYear           = Convert.ToInt32(vehicleToBrakeConfigSearchInputModel.EndYear),
                Makes             = vehicleToBrakeConfigSearchInputModel.Makes,
                Models            = vehicleToBrakeConfigSearchInputModel.Models,
                SubModels         = vehicleToBrakeConfigSearchInputModel.SubModels,
                VehicleTypes      = vehicleToBrakeConfigSearchInputModel.VehicleTypes,
                VehicleTypeGroups = vehicleToBrakeConfigSearchInputModel.VehicleTypeGroups,
                Regions           = vehicleToBrakeConfigSearchInputModel.Regions,
            };

            bool isEndReached = false;
            int  pageNumber   = 1;

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

                if (result != null && result.Documents != null && result.Documents.Any())
                {
                    vehicleToBrakeConfigs.AddRange(_vehicleToBrakeConfigViewModelMapper.Map(result));

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

            return(vehicleToBrakeConfigs);
        }
        private async Task <string[]> RefreshBrakeSystemFacet(VehicleToBrakeConfigSearchInputModel vehicleToBrakeConfigSearchInputModel)
        {
            var applyFilters = new VehicleToBrakeConfigSearchFilters()
            {
            };

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

            var vehicleToBrakeConfigSearchViewModel = _vehicleToBrakeConfigSearchViewModelMapper.Map(result);

            return(vehicleToBrakeConfigSearchViewModel.Facets.BrakeSystems);
        }
        public async Task <List <VehicleToBrakeConfigViewModel> > Search(List <string> vehicleIdArray /*string vehicleIds*/)
        {
            List <VehicleToBrakeConfigViewModel> vehicleToBrakeConfigs = null;

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

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

                vehicleToBrakeConfigs = _vehicleToBrakeConfigViewModelMapper.Map(result);
            }
            return(vehicleToBrakeConfigs);
        }