Ejemplo n.º 1
0
        public async Task <CreateStepVariableResponse> Post(CreateStepVariableRequest 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);
            }

            if (await stepRepository.DoesStepVariableExist(request.BatchId, request.StepName, request.VariableName))
            {
                throw Err.StepVariableAlreadyExists(request.VariableName);
            }

            var stepVariable = request.ConvertTo <StepVariable>();

            stepVariable.StepId = step.Id;

            await stepRepository.CreateOrUpdateStepVariable(stepVariable);

            return(new CreateStepVariableResponse());
        }