Solves issue #611
This commit is contained in:
parent
6127457e8e
commit
89fb5d6fc3
@ -1,5 +1,6 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -7,7 +8,7 @@
|
||||
{
|
||||
Task<Order> GetOrderAsync(int id);
|
||||
|
||||
Task<IEnumerable<OrderSummary>> GetOrdersAsync();
|
||||
Task<IEnumerable<OrderSummary>> GetOrdersFromUserAsync(Guid userId);
|
||||
|
||||
Task<IEnumerable<CardType>> GetCardTypesAsync();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<OrderSummary>> GetOrdersAsync()
|
||||
public async Task<IEnumerable<OrderSummary>> GetOrdersFromUserAsync(Guid userId)
|
||||
{
|
||||
using (var connection = new SqlConnection(_connectionString))
|
||||
{
|
||||
@ -52,8 +52,10 @@
|
||||
FROM [ordering].[Orders] o
|
||||
LEFT JOIN[ordering].[orderitems] oi ON o.Id = oi.orderid
|
||||
LEFT JOIN[ordering].[orderstatus] os on o.OrderStatusId = os.Id
|
||||
LEFT JOIN[ordering].[buyers] ob on o.BuyerId = ob.Id
|
||||
WHERE ob.IdentityGuid = @userId
|
||||
GROUP BY o.[Id], o.[OrderDate], os.[Name]
|
||||
ORDER BY o.[Id]");
|
||||
ORDER BY o.[Id]", new { userId });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers
|
||||
[ProducesResponseType(typeof(IEnumerable<OrderSummary>), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetOrders()
|
||||
{
|
||||
var orders = await _orderQueries.GetOrdersAsync();
|
||||
|
||||
var userid = _identityService.GetUserIdentity();
|
||||
var orders = await _orderQueries.GetOrdersFromUserAsync(Guid.Parse(userid));
|
||||
return Ok(orders);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace UnitTest.Ordering.Application
|
||||
{
|
||||
//Arrange
|
||||
var fakeDynamicResult = Enumerable.Empty<OrderSummary>();
|
||||
_orderQueriesMock.Setup(x => x.GetOrdersAsync())
|
||||
_orderQueriesMock.Setup(x => x.GetOrdersFromUserAsync(Guid.NewGuid()))
|
||||
.Returns(Task.FromResult(fakeDynamicResult));
|
||||
|
||||
//Act
|
||||
|
Loading…
x
Reference in New Issue
Block a user