feat: update GetOrderByIdQuery to allow nullable UserId and adjust query handling in GetOrderByIdQueryHandler
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m43s

This commit is contained in:
masoodafar-web
2026-05-05 01:54:33 +03:30
parent f7d6b0e3e7
commit 65db839642
3 changed files with 16 additions and 4 deletions
@@ -15,8 +15,15 @@ public class GetOrderByIdQueryHandler : IRequestHandler<GetOrderByIdQuery, Order
public async Task<OrderDetailDto?> Handle(GetOrderByIdQuery request, CancellationToken cancellationToken)
{
var order = await _context.DiscountOrders
.Where(o => o.Id == request.OrderId && o.UserId == request.UserId)
var query = _context.DiscountOrders
.Where(o => o.Id == request.OrderId);
if (request.UserId.HasValue && request.UserId.Value > 0)
{
query = query.Where(o => o.UserId == request.UserId.Value);
}
var order = await query
.Include(o => o.UserAddress)
.Include(o => o.OrderDetails)
.ThenInclude(od => od.Product)