Skip to content

Commit 1d832a6

Browse files
committed
Add OrderingDomainException when the order doesn't exist with id orderId
1 parent 985428b commit 1d832a6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.EntityFrameworkCore;
22
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
33
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
4+
using Ordering.Domain.Exceptions;
45
using System;
56
using System.Threading.Tasks;
67

@@ -32,7 +33,8 @@ public Order Add(Order order)
3233

3334
public async Task<Order> GetAsync(int orderId)
3435
{
35-
return await _context.Orders.FindAsync(orderId);
36+
return await _context.Orders.FindAsync(orderId)
37+
?? throw new OrderingDomainException($"Not able to get the order. Reason: no valid orderId: {orderId}");
3638
}
3739

3840
public void Update(Order order)

0 commit comments

Comments
 (0)