public override async Task <List <OrderDetailsViewModel> > ExecuteQuery(GetOrdersQuery query,
                                                                            CancellationToken cancellationToken)
    {
        List <OrderDetailsViewModel> viewModelList = new List <OrderDetailsViewModel>();

        var customerId = new CustomerId(query.CustomerId);
        var customer   = await _unitOfWork.Customers
                         .GetById(customerId, cancellationToken);

        if (customer == null)
        {
            throw new ApplicationDataException("Custumer not found.");
        }

        var isOrderPlacedByCustomer = new IsOrderPlacedByCustomer(customer.Id);
        var customerOrders          = await _unitOfWork.Orders.Find(isOrderPlacedByCustomer);

        foreach (var order in customerOrders)
        {
            var productIds = order.OrderLines.
                             Select(p => p.ProductId).ToList();

            var products = await _unitOfWork.Products
                           .GetByIds(productIds, cancellationToken);

            OrderDetailsViewModel viewModel = new OrderDetailsViewModel();
            viewModel.OrderId   = order.Id.Value;
            viewModel.CreatedAt = order.CreatedAt.ToString();
            viewModel.Status    = OrderStatusPrettier.Prettify(order.Status);

            foreach (var orderLine in order.OrderLines)
            {
                var product = products.Single(
                    (System.Func <Domain.Products.Product, bool>)
                        (p => p.Id == orderLine.ProductId));

                var currency = Currency
                               .FromCode(orderLine.ProductExchangePrice.CurrencyCode);

                viewModel.OrderLines.Add(new OrderLinesDetailsViewModel
                {
                    ProductId       = orderLine.ProductId.Value,
                    ProductQuantity = orderLine.Quantity,
                    ProductPrice    = orderLine.ProductExchangePrice.Value,
                    ProductName     = product.Name,
                    CurrencySymbol  = currency.Symbol,
                });
            }

            viewModel.CalculateTotalOrderPrice();
            viewModelList.Add(viewModel);
        }

        return(viewModelList);
    }
    public async Task BroadcastOrderStatus(
        CustomerId customerId,
        OrderId orderId,
        OrderStatus orderStatus)
    {
        try
        {
            var prettyStatus = OrderStatusPrettier
                               .Prettify(orderStatus);

            await _broadCastHub.Clients
            .Groups(customerId.Value.ToString())
            .UpdateOrderStatus(
                orderId.Value.ToString(),
                prettyStatus
                );
        }
        catch (Exception ex)
        {
            _logger.LogError($"\n--- An error has occurred while broadcasting status for order {orderId.Value}: {ex.Message}\n");
        }
    }