public async Task <IEnumerable <OrderViewModel> > Handle(GetAdminOrders request, CancellationToken cancellationToken)
        {
            var specification = new AdminOrdersSpecification(
                request.BuyerId,
                request.CreatedBefore,
                request.CreatedAfter);
            var orders = await _orderRepository.ListAsync(specification);

            return(orders.Select(order => order.CreateViewModel()));
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <OrderViewModel> > Handle(GetAdminOrders request, CancellationToken cancellationToken)
        {
            var specification = new CustomerOrdersWithItemsSpecification();
            var orders        = await _orderRepository.ListAsync(specification);

            return(orders.Select(o => new OrderViewModel
            {
                OrderDate = o.OrderDate,
                OrderBy = o.BuyerId,
                OrderItems = o.OrderItems?.Select(oi => new OrderItemViewModel()
                {
                    PictureUrl = oi.ItemOrdered.PictureUri,
                    ProductId = oi.ItemOrdered.CatalogItemId,
                    ProductName = oi.ItemOrdered.ProductName,
                    UnitPrice = oi.UnitPrice,
                    Units = oi.Units
                }).ToList(),
                OrderNumber = o.Id,
                ShippingAddress = o.ShipToAddress,
                Status = o.OrderStatus,
                Commentes = o.Comments,
                Total = o.Total()
            }));
        }