Exemple #1
0
        public async Task <CreateCommandResponse> Post(CreateCommandRequest 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 commandRepository.DoesCommandExist(request.BatchId, request.StepName, request.CommandName))
            {
                throw Err.CommandAlreadyExists(request.CommandName);
            }

            var command = request.ConvertTo <Core.Entities.Command>();

            command.StepId = step.Id;

            await commandRepository.Create(command);

            return(new CreateCommandResponse());
        }