From ea1c50db7b9f8f57439d01ddac9ec462c9fd5ad0 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 16 May 2017 10:18:28 +0200 Subject: [PATCH] Add OrderingDomainException when the order doesn't exist with id orderId --- .../Ordering.Infrastructure/Repositories/OrderRepository.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs b/src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs index 53f0ad92a..5c0c3ef8c 100644 --- a/src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs +++ b/src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; +using Ordering.Domain.Exceptions; using System; using System.Threading.Tasks; @@ -32,7 +33,8 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositor public async Task GetAsync(int orderId) { - return await _context.Orders.FindAsync(orderId); + return await _context.Orders.FindAsync(orderId) + ?? throw new OrderingDomainException($"Not able to get the order. Reason: no valid orderId: {orderId}"); } public void Update(Order order)