Example #1
0
        public async Task <CreateStepArtifactOptionResponse> Post(CreateStepArtifactOptionRequest 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 existingStepArtifact =
                await stepRepository.GetStepArtifact(step.Id, request.ArtifactName);

            if (existingStepArtifact == null)
            {
                throw Err.StepArtifactNotFound(request.ArtifactName);
            }

            if (await stepRepository.DoesStepArtifactOptionExist(request.BatchId, request.StepName, request.ArtifactName, request.OptionName))
            {
                throw Err.StepArtifactOptionAlreadyExists(request.OptionName);
            }

            var stepArtifactOption = request.ConvertTo <StepArtifactOption>();

            stepArtifactOption.StepArtifactId = existingStepArtifact.Id;

            await stepRepository.CreateOrUpdateStepArtifactOption(stepArtifactOption);

            return(new CreateStepArtifactOptionResponse());
        }