public async Task <UpdateBatchArtifactOptionResponse> Put(UpdateBatchArtifactOptionRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName); if (batchArtifact == null) { throw Err.BatchArtifactNotFound(request.ArtifactName); } var existingBatchArtifactOption = await batchRepository.GetBatchArtifactOption(batchArtifact.Id, request.OptionName); if (existingBatchArtifactOption == null) { throw Err.BatchArtifactOptionNotFound(request.OptionName); } var batchArtifactOption = request.ConvertTo <BatchArtifactOption>(); batchArtifactOption.Id = existingBatchArtifactOption.Id; batchArtifactOption.BatchArtifactId = batchArtifact.Id; await batchRepository.CreateOrUpdateBatchArtifactOption(batchArtifactOption); return(new UpdateBatchArtifactOptionResponse()); }
public async Task <DeleteBatchArtifactOptionResponse> Delete(DeleteBatchArtifactOptionRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName); if (batchArtifact == null) { throw Err.BatchArtifactNotFound(request.ArtifactName); } var existingBatchArtifactOption = await batchRepository.GetBatchArtifactOption(batchArtifact.Id, request.OptionName); if (existingBatchArtifactOption == null) { throw Err.BatchArtifactOptionNotFound(request.OptionName); } await batchRepository.DeleteBatchArtifactOption(existingBatchArtifactOption.Id); return(new DeleteBatchArtifactOptionResponse()); }
public async Task <GetBatchArtifactOptionResponse> Get(GetBatchArtifactOptionRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName); if (batchArtifact == null) { throw Err.BatchArtifactNotFound(request.ArtifactName); } var batchArtifactOption = await batchRepository.GetBatchArtifactOption(batchArtifact.Id, request.OptionName); if (batchArtifactOption == null) { throw Err.BatchArtifactOptionNotFound(request.OptionName); } return(batchArtifactOption.ConvertTo <GetBatchArtifactOptionResponse>()); }