public async Task <VehicleSearchResult> SearchAsync(string searchText, string filter = null, SearchOptions searchOptions = null) { //NOTE: auto cast from SearchResult<VehicleDocument> to VehicleSearchResult did not work //return await _vehicleSearchRepositoryService.SearchAsync(searchText, filter, searchOptions) as VehicleSearchResult; var result = await _vehicleSearchRepositoryService.SearchAsync(searchText, filter, searchOptions); VehicleSearchResult vehicleSearchResult = new VehicleSearchResult() { Documents = result.Documents, Facets = result.Facets, TotalCount = result.TotalCount }; return(vehicleSearchResult); }
public async Task Handle(ApplyMakeNameChange payload) { if (payload?.Make == null) { return; } var make = payload.Make; var vehicleSearchResult = await _vehicleSearchRepositoryService.SearchAsync(null, x => x.MakeId == make.Id) as VehicleSearchResult; if (vehicleSearchResult?.Documents == null || !vehicleSearchResult.Documents.Any()) { return; } foreach (var vehicle in vehicleSearchResult.Documents) { vehicle.MakeName = make.Name; } var documentIndexingResult = await _vehicleIndexRepositoryService.UpdateDocumentsAsync(vehicleSearchResult.Documents.ToList()); }