Exemplo n.º 1
0
        public async Task <DeleteCommandVariableResponse> Delete(DeleteCommandVariableRequest 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);
            }

            var existingCommandVariable =
                await commandRepository.GetCommandVariable(command.Id, request.VariableName);

            if (existingCommandVariable == null)
            {
                throw Err.CommandVariableNotFound(request.VariableName);
            }

            await commandRepository.DeleteCommandVariable(existingCommandVariable.Id);

            return(new DeleteCommandVariableResponse());
        }
Exemplo n.º 2
0
        public async Task <GetCommandVariableResponse> Get(GetCommandVariableRequest 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);
            }

            var commandVariable = await commandRepository.GetCommandVariable(command.Id, request.VariableName);

            if (commandVariable == null)
            {
                throw Err.CommandVariableNotFound(request.VariableName);
            }

            return(commandVariable.ConvertTo <GetCommandVariableResponse>());
        }
Exemplo n.º 3
0
        public async Task <UpdateCommandVariableResponse> Put(UpdateCommandVariableRequest 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);
            }

            var existingCommandVariable =
                await commandRepository.GetCommandVariable(command.Id, request.VariableName);

            if (existingCommandVariable == null)
            {
                throw Err.CommandVariableNotFound(request.VariableName);
            }

            var commandVariable = request.ConvertTo <CommandVariable>();

            commandVariable.Id        = existingCommandVariable.Id;
            commandVariable.CommandId = command.Id;

            await commandRepository.CreateOrUpdateCommandVariable(commandVariable);

            return(new UpdateCommandVariableResponse());
        }