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

            await commandRepository.DeleteCommandOption(existingCommandOption.Id);

            return(new DeleteCommandOptionResponse());
        }
Exemplo n.º 2
0
        public async Task <GetCommandOptionResponse> Get(GetCommandOptionRequest 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 commandOption = await commandRepository.GetCommandOption(command.Id, request.OptionName);

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

            return(commandOption.ConvertTo <GetCommandOptionResponse>());
        }
Exemplo n.º 3
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());
        }