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>()); }
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()); }
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()); }