Skip to content

Commit

Permalink
fixbug: get orders
Browse files Browse the repository at this point in the history
  • Loading branch information
datsunbae committed Apr 20, 2024
1 parent 50a2a05 commit a2c5933
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task<Result<PaginationResponse<OrderResponse>>> Handle(
return await _orderRepository
.PaginatedListAsync(
new OrderByUserIdPaginatedSpec(request, _currentUser),
request.PageSize,
request.PageNumber);
request.PageNumber,
request.PageSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
using CleanArchitecture.Application.Features.V1.Orders.Models.Responses;
using CleanArchitecture.Application.Features.V1.Orders.Queries.GetOrderByUserId;
using CleanArchitecture.Domain.AggregatesModels.Orders;
using CleanArchitecture.Domain.Constants.Authorization;

namespace CleanArchitecture.Application.Features.V1.Orders.Specifications;

public class OrderByUserIdPaginatedSpec : EntitiesByPaginationFilterSpec<Order, OrderResponse>
{
public OrderByUserIdPaginatedSpec(GetOrderByUserIdQuery request, ICurrentUser currentUser) : base(request)
{
Query
.Where(o => o.UserId == currentUser.GetUserId());
if(currentUser.IsInRole(Roles.Customer))
{
Query
.Where(o => o.UserId == currentUser.GetUserId());
}
}
}

0 comments on commit a2c5933

Please sign in to comment.