public async Task AddChangeRequestIndexerAsync(long changeRequestId) { var brakeConfigRepositoryService = _vcdbUnitOfWork.GetRepositoryService <BrakeConfig>() as IVcdbSqlServerEfRepositoryService <BrakeConfig>; if (brakeConfigRepositoryService == null) { return; } var addedBrakeConfigs = await brakeConfigRepositoryService.GetAsync( item => item.ChangeRequestId == changeRequestId, 100000, "BrakeABS", "BrakeSystem", "FrontBrakeType", "RearBrakeType"); if (addedBrakeConfigs == null || !addedBrakeConfigs.Any()) { throw new InvalidOperationException( "Brake Config Index cannot be updated before the transactional table is updated"); } var addedBrakeConfig = addedBrakeConfigs.First(); var vehicleToBrakeConfigSearchResult = await _vehicletoBrakeConfigSearchService.SearchAsync(null, $"brakeConfigId eq {addedBrakeConfig.Id}"); var existingVehicleToBrakeConfigDocuments = vehicleToBrakeConfigSearchResult.Documents; if (existingVehicleToBrakeConfigDocuments != null && existingVehicleToBrakeConfigDocuments.Any()) { throw new InvalidOperationException( "BrakeConfig already exisit in VehicleToBrakeConfigIndex. So, this change request cannot be an add request"); } //brake config is new and therefore not yet available in "vehicletobrakeconfigs" azure search index VehicleToBrakeConfigDocument newVehicleToBrakeConfigDocument = new VehicleToBrakeConfigDocument { VehicleToBrakeConfigId = Guid.NewGuid().ToString(), BrakeConfigId = addedBrakeConfig.Id, FrontBrakeTypeId = addedBrakeConfig.FrontBrakeTypeId, FrontBrakeTypeName = addedBrakeConfig.FrontBrakeType.Name, RearBrakeTypeId = addedBrakeConfig.RearBrakeTypeId, RearBrakeTypeName = addedBrakeConfig.RearBrakeType.Name, BrakeABSId = addedBrakeConfig.BrakeABSId, BrakeABSName = addedBrakeConfig.BrakeABS.Name, BrakeSystemId = addedBrakeConfig.BrakeSystemId, BrakeSystemName = addedBrakeConfig.BrakeSystem.Name, }; await this._vehicleToBrakeConfigIndexingService.UploadDocumentAsync(newVehicleToBrakeConfigDocument); }
public async Task UpdateVehicleToBrakeConfigChangeRequestIdAsync(int vehicleToBrakeConfigId, long vehicleToBrakeConfigChangeRequestId) { VehicleToBrakeConfigDocument document = new VehicleToBrakeConfigDocument { VehicleToBrakeConfigId = vehicleToBrakeConfigId.ToString(), VehicleToBrakeConfigChangeRequestId = vehicleToBrakeConfigChangeRequestId, }; await _vehicleToBrakeConfigIndexingRepositoryService.UpdateDocumentAsync(document); }
private async Task InsertOrUpdateVehicleToBrakeConfigDocuments(List <VehicleToBrakeConfig> updatedVehicleToBrakeConfigs, bool isReplace = false) { if (updatedVehicleToBrakeConfigs == null) { return; } foreach (var updatedVehicleToBrakeConfig in updatedVehicleToBrakeConfigs) //NOTE: updatedVehicles will contain more than 1 item when processing base vehicle replace { var vehicletoBrakeConfigDocument = new VehicleToBrakeConfigDocument { VehicleToBrakeConfigId = updatedVehicleToBrakeConfig.Id.ToString(), BrakeConfigChangeRequestId = isReplace ? -1 : (long?)null, VehicleToBrakeConfigChangeRequestId = -1, BaseVehicleId = updatedVehicleToBrakeConfig.Vehicle.BaseVehicleId, BrakeABSId = updatedVehicleToBrakeConfig.BrakeConfig.BrakeABSId, BrakeABSName = updatedVehicleToBrakeConfig.BrakeConfig.BrakeABS.Name, BrakeConfigId = updatedVehicleToBrakeConfig.BrakeConfigId, BrakeSystemId = updatedVehicleToBrakeConfig.BrakeConfig.BrakeSystemId, BrakeSystemName = updatedVehicleToBrakeConfig.BrakeConfig.BrakeSystem.Name, FrontBrakeTypeId = updatedVehicleToBrakeConfig.BrakeConfig.FrontBrakeTypeId, FrontBrakeTypeName = updatedVehicleToBrakeConfig.BrakeConfig.FrontBrakeType.Name, RearBrakeTypeId = updatedVehicleToBrakeConfig.BrakeConfig.RearBrakeTypeId, RearBrakeTypeName = updatedVehicleToBrakeConfig.BrakeConfig.RearBrakeType.Name, MakeId = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.MakeId, MakeName = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.Make.Name, ModelId = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.ModelId, ModelName = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.Model.Name, RegionId = updatedVehicleToBrakeConfig.Vehicle.RegionId, RegionName = updatedVehicleToBrakeConfig.Vehicle.Region.Name, Source = updatedVehicleToBrakeConfig.Vehicle.SourceName, SubModelId = updatedVehicleToBrakeConfig.Vehicle.SubModelId, SubModelName = updatedVehicleToBrakeConfig.Vehicle.SubModel.Name, VehicleId = updatedVehicleToBrakeConfig.VehicleId, VehicleTypeGroupId = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.Model.VehicleType.VehicleTypeGroupId, VehicleTypeGroupName = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.Model.VehicleType.VehicleTypeGroup.Name, VehicleTypeId = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.Model.VehicleTypeId, VehicleTypeName = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.Model.VehicleType.Name, YearId = updatedVehicleToBrakeConfig.Vehicle.BaseVehicle.YearId, }; await this._vehicleToBrakeConfigIndexingService.UploadDocumentAsync(vehicletoBrakeConfigDocument); } }
public async Task RejectChangeRequestIndexerAsync(long changeRequestId) { var vehicletoBrakeConfigRepositoryService = _vcdbUnitOfWork.GetRepositoryService <VehicleToBrakeConfig>() as IVcdbSqlServerEfRepositoryService <VehicleToBrakeConfig>; if (vehicletoBrakeConfigRepositoryService == null) { return; } var updatedVehicleToBrakeConfigs = await vehicletoBrakeConfigRepositoryService.GetAsync(item => item.ChangeRequestId == changeRequestId); if (updatedVehicleToBrakeConfigs == null || !updatedVehicleToBrakeConfigs.Any()) { //Pushkar: need to test this condition throw new InvalidOperationException( "Vehicle To Brake Config Index cannot be updated before the transactional table is updated"); } foreach (var updatedVehicleToBrakeConfig in updatedVehicleToBrakeConfigs) { var vehicletoBrakeConfigDocument = new VehicleToBrakeConfigDocument { VehicleToBrakeConfigId = updatedVehicleToBrakeConfig.Id.ToString(), VehicleToBrakeConfigChangeRequestId = -1, }; await this._vehicleToBrakeConfigIndexingService.UploadDocumentAsync(vehicletoBrakeConfigDocument); } //Required when processing brakeconfig REPLACE CR await ClearBrakeConfigChangeRequestId(changeRequestId); }
public async Task <DocumentIndexResult> UpdateDocumentAsync(VehicleToBrakeConfigDocument vehicleToBrakeConfigDocument) { return(await UpdateDocumentsAsync(new List <VehicleToBrakeConfigDocument> { vehicleToBrakeConfigDocument })); }
public Task UploadDocumentAsync(VehicleToBrakeConfigDocument vehicleToBrakeConfigDocument) { throw new NotImplementedException(); }
public async Task UploadDocumentAsync(VehicleToBrakeConfigDocument vehicleToBrakeConfigDocument) { await _vehicleToBrakeConfigIndexingRepositoryService.UpdateDocumentAsync(vehicleToBrakeConfigDocument); }