Exemplo n.º 1
0
        public async Task <UpdateBatchArtifactOptionResponse> Put(UpdateBatchArtifactOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName);

            if (batchArtifact == null)
            {
                throw Err.BatchArtifactNotFound(request.ArtifactName);
            }

            var existingBatchArtifactOption =
                await batchRepository.GetBatchArtifactOption(batchArtifact.Id, request.OptionName);

            if (existingBatchArtifactOption == null)
            {
                throw Err.BatchArtifactOptionNotFound(request.OptionName);
            }

            var batchArtifactOption = request.ConvertTo <BatchArtifactOption>();

            batchArtifactOption.Id = existingBatchArtifactOption.Id;
            batchArtifactOption.BatchArtifactId = batchArtifact.Id;

            await batchRepository.CreateOrUpdateBatchArtifactOption(batchArtifactOption);

            return(new UpdateBatchArtifactOptionResponse());
        }
Exemplo n.º 2
0
        public async Task <DeleteBatchArtifactOptionResponse> Delete(DeleteBatchArtifactOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName);

            if (batchArtifact == null)
            {
                throw Err.BatchArtifactNotFound(request.ArtifactName);
            }

            var existingBatchArtifactOption =
                await batchRepository.GetBatchArtifactOption(batchArtifact.Id, request.OptionName);

            if (existingBatchArtifactOption == null)
            {
                throw Err.BatchArtifactOptionNotFound(request.OptionName);
            }

            await batchRepository.DeleteBatchArtifactOption(existingBatchArtifactOption.Id);

            return(new DeleteBatchArtifactOptionResponse());
        }
Exemplo n.º 3
0
        public async Task <GetBatchArtifactOptionResponse> Get(GetBatchArtifactOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchArtifact = await batchRepository.GetBatchArtifact(request.BatchId, request.ArtifactName);

            if (batchArtifact == null)
            {
                throw Err.BatchArtifactNotFound(request.ArtifactName);
            }

            var batchArtifactOption = await batchRepository.GetBatchArtifactOption(batchArtifact.Id, request.OptionName);

            if (batchArtifactOption == null)
            {
                throw Err.BatchArtifactOptionNotFound(request.OptionName);
            }

            return(batchArtifactOption.ConvertTo <GetBatchArtifactOptionResponse>());
        }