示例#1
0
        public async Task <GetBatchOptionResponse> Get(GetBatchOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchOption = await batchRepository.GetBatchOption(request.BatchId, request.OptionName);

            if (batchOption == null)
            {
                throw Err.BatchOptionNotFound(request.OptionName);
            }

            return(batchOption.ConvertTo <GetBatchOptionResponse>());
        }
示例#2
0
        public async Task <DeleteBatchOptionResponse> Delete(DeleteBatchOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var existingBatchOption =
                await batchRepository.GetBatchOption(request.BatchId, request.OptionName);

            if (existingBatchOption == null)
            {
                throw Err.BatchOptionNotFound(request.OptionName);
            }

            await batchRepository.DeleteBatchOption(existingBatchOption.Id);

            return(new DeleteBatchOptionResponse());
        }
示例#3
0
        public async Task <UpdateBatchOptionResponse> Put(UpdateBatchOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var existingBatchOption =
                await batchRepository.GetBatchOption(request.BatchId, request.OptionName);

            if (existingBatchOption == null)
            {
                throw Err.BatchOptionNotFound(request.OptionName);
            }

            var batchOption = request.ConvertTo <BatchOption>();

            batchOption.Id = existingBatchOption.Id;

            await batchRepository.CreateOrUpdateBatchOption(batchOption);

            return(new UpdateBatchOptionResponse());
        }