public async Task <CreateCommandVariableResponse> Post(CreateCommandVariableRequest request) { if (!await batchRepository.DoesBatchExist(request.BatchId)) { throw Err.BatchNotFound(request.BatchId); } var step = await stepRepository.Get(request.BatchId, request.StepName); if (step == null) { throw Err.StepNotFound(request.StepName); } var command = await commandRepository.Get(step.Id, request.CommandName); if (command == null) { throw Err.CommandNotFound(request.CommandName); } if (await commandRepository.DoesCommandVariableExist(request.BatchId, request.StepName, request.CommandName, request.VariableName)) { throw Err.CommandVariableAlreadyExists(request.VariableName); } var commandVariable = request.ConvertTo <CommandVariable>(); commandVariable.CommandId = command.Id; await commandRepository.CreateOrUpdateCommandVariable(commandVariable); return(new CreateCommandVariableResponse()); }