Browse Source

Merge pull request #142 from abpframework/eshop-anonymous-issue

Removed unnecessary [AllowAnonymous]
pull/188/head
Galip Tolga Erdem 3 years ago
committed by GitHub
parent
commit
ca32f0dac9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs

11
services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs

@ -37,14 +37,8 @@ public class OrderAppService : ApplicationService, IOrderAppService
return CreateOrderDtoMapping(order); return CreateOrderDtoMapping(order);
} }
[AllowAnonymous]
public async Task<List<OrderDto>> GetMyOrdersAsync(GetMyOrdersInput input) public async Task<List<OrderDto>> GetMyOrdersAsync(GetMyOrdersInput input)
{ {
if (CurrentUser.Id == null)
{
return new List<OrderDto>();
}
ISpecification<Order> specification = SpecificationFactory.Create(input.Filter); ISpecification<Order> specification = SpecificationFactory.Create(input.Filter);
var orders = await _orderRepository.GetOrdersByUserId(CurrentUser.GetId(), specification, true); var orders = await _orderRepository.GetOrdersByUserId(CurrentUser.GetId(), specification, true);
return CreateOrderDtoMapping(orders); return CreateOrderDtoMapping(orders);
@ -78,6 +72,7 @@ public class OrderAppService : ApplicationService, IOrderAppService
Payments = await GetPercentOfTotalPaymentAsync(input.Filter) Payments = await GetPercentOfTotalPaymentAsync(input.Filter)
}; };
} }
private async Task<List<TopSellingDto>> GetTopSellingAsync(string filter) private async Task<List<TopSellingDto>> GetTopSellingAsync(string filter)
{ {
ISpecification<Order> specification = SpecificationFactory.Create(filter); ISpecification<Order> specification = SpecificationFactory.Create(filter);
@ -99,7 +94,6 @@ public class OrderAppService : ApplicationService, IOrderAppService
return CreateOrderStatusDtoMapping(orders); return CreateOrderStatusDtoMapping(orders);
} }
[AllowAnonymous]
public async Task<OrderDto> GetByOrderNoAsync(int orderNo) public async Task<OrderDto> GetByOrderNoAsync(int orderNo)
{ {
var order = await _orderRepository.GetByOrderNoAsync(orderNo); var order = await _orderRepository.GetByOrderNoAsync(orderNo);
@ -122,7 +116,6 @@ public class OrderAppService : ApplicationService, IOrderAppService
await _orderRepository.UpdateAsync(order); await _orderRepository.UpdateAsync(order);
} }
[AllowAnonymous]
public async Task<OrderDto> CreateAsync(OrderCreateDto input) public async Task<OrderDto> CreateAsync(OrderCreateDto input)
{ {
var orderItems = GetProductListTuple(input.Products); var orderItems = GetProductListTuple(input.Products);
@ -211,7 +204,7 @@ public class OrderAppService : ApplicationService, IOrderAppService
var topSetlling = orderItems var topSetlling = orderItems
.GroupBy(p => p.ProductId) .GroupBy(p => p.ProductId)
.Select(p => new TopSellingDto { Units = p.Count(), ProductName = p.First().ProductName , PictureUrl = p.First().PictureUrl }) .Select(p => new TopSellingDto { Units = p.Count(), ProductName = p.First().ProductName, PictureUrl = p.First().PictureUrl })
.OrderByDescending(p => p.Units) .OrderByDescending(p => p.Units)
.Take(OrderConstants.Top10).ToList(); .Take(OrderConstants.Top10).ToList();

Loading…
Cancel
Save