From 8bd20ef98bff48ce637d221b93086c2c92c91999 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Mon, 11 Jun 2018 14:28:09 -0400 Subject: [PATCH] Fix OrderDetails to use Id, Customer Fixes #106 --- .../Specifications/BasketWithItemsSpecification.cs | 3 +-- src/Web/Controllers/OrderController.cs | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ApplicationCore/Specifications/BasketWithItemsSpecification.cs b/src/ApplicationCore/Specifications/BasketWithItemsSpecification.cs index 7860862..bc96e34 100644 --- a/src/ApplicationCore/Specifications/BasketWithItemsSpecification.cs +++ b/src/ApplicationCore/Specifications/BasketWithItemsSpecification.cs @@ -1,5 +1,4 @@ -using Microsoft.eShopWeb.ApplicationCore.Entities; -using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate; +using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate; namespace Microsoft.eShopWeb.ApplicationCore.Specifications { diff --git a/src/Web/Controllers/OrderController.cs b/src/Web/Controllers/OrderController.cs index c8f0e07..acff1f7 100644 --- a/src/Web/Controllers/OrderController.cs +++ b/src/Web/Controllers/OrderController.cs @@ -49,7 +49,12 @@ namespace Microsoft.eShopWeb.Web.Controllers [HttpGet("{orderId}")] public async Task Detail(int orderId) { - var order = await _orderRepository.GetByIdWithItemsAsync(orderId); + var customerOrders = await _orderRepository.ListAsync(new CustomerOrdersWithItemsSpecification(User.Identity.Name)); + var order = customerOrders.FirstOrDefault(o => o.Id == orderId); + if (order == null) + { + return BadRequest("No such order found for this user."); + } var viewModel = new OrderViewModel() { OrderDate = order.OrderDate,