public async Task <GetBatchVariableResponse> Get(GetBatchVariableRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var batchVariable = await batchRepository.GetBatchVariable(request.BatchId, request.VariableName); if (batchVariable == null) { throw Err.BatchVariableNotFound(request.VariableName); } return(batchVariable.ConvertTo <GetBatchVariableResponse>()); }
public async Task <DeleteBatchVariableResponse> Delete(DeleteBatchVariableRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var existingBatchVariable = await batchRepository.GetBatchVariable(request.BatchId, request.VariableName); if (existingBatchVariable == null) { throw Err.BatchVariableNotFound(request.VariableName); } await batchRepository.DeleteBatchVariable(existingBatchVariable.Id); return(new DeleteBatchVariableResponse()); }
public async Task <UpdateBatchVariableResponse> Put(UpdateBatchVariableRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var existingBatchVariable = await batchRepository.GetBatchVariable(request.BatchId, request.VariableName); if (existingBatchVariable == null) { throw Err.BatchVariableNotFound(request.VariableName); } var batchVariable = request.ConvertTo <BatchVariable>(); batchVariable.Id = existingBatchVariable.Id; await batchRepository.CreateOrUpdateBatchVariable(batchVariable); return(new UpdateBatchVariableResponse()); }