Пример #1
0
        public async Task <GetAllCommandVariableResponse> Get(GetAllCommandVariableRequest 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 response = new GetAllCommandVariableResponse
            {
                Variables = command.Variables.ConvertTo <List <DomainModels.Variable> >()
            };

            return(response);
        }
Пример #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>());
        }
Пример #3
0
        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());
        }
Пример #4
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());
        }
Пример #5
0
        public async Task <UpdateCommandResponse> Put(UpdateCommandRequest 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 = request.ConvertTo <Core.Entities.Command>();

            command.StepId = step.Id;

            var updated = await commandRepository.Update(command);

            if (!updated)
            {
                throw Err.CommandNotFound(request.CommandName);
            }

            return(new UpdateCommandResponse());
        }
Пример #6
0
        public async Task <UpdateCommandOptionResponse> Put(UpdateCommandOptionRequest 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 existingCommandOption =
                await commandRepository.GetCommandOption(command.Id, request.OptionName);

            if (existingCommandOption == null)
            {
                throw Err.CommandOptionNotFound(request.OptionName);
            }

            var commandOption = request.ConvertTo <CommandOption>();

            commandOption.Id        = existingCommandOption.Id;
            commandOption.CommandId = command.Id;

            await commandRepository.CreateOrUpdateCommandOption(commandOption);

            return(new UpdateCommandOptionResponse());
        }