public async Task <IEnumerable <OrderDto> > GetOrdersClient(Guid clientId) { var orders = await _orderRepository.GetOrderByClientId(clientId); orders = orders.Where(o => o.OrderStatus == OrderStatus.Paid || o.OrderStatus == OrderStatus.Canceled).OrderByDescending(o => o.Code).ToList(); if (!orders.Any()) { return(null); } return(orders.Select(order => OrderDto.Create(order.TotalValue, (int)order.OrderStatus, order.Code, order.CreatedDate)).ToList()); }
public async Task <IEnumerable <OrderDto> > GetOrders(string userId) { var orders = await _context.Orders .Where(o => o.UserId.Equals(userId)) .Include(o => o.BillingAddress).ToListAsync(); var output = new List <OrderDto>(); foreach (var order in orders) { output.Add(OrderDto.Create(order, await GetPurchases(userId, order.Id))); } return(output); }