public OrdersListViewModel(OrderInfo order, ICurrencyInfoProvider currencyInfoProvider, IOrderStatusInfoProvider orderStatusInfoProvider)
        {
            if (order == null)
            {
                return;
            }

            if (currencyInfoProvider == null)
            {
                throw new ArgumentNullException(nameof(currencyInfoProvider));
            }

            if (orderStatusInfoProvider == null)
            {
                throw new ArgumentNullException(nameof(orderStatusInfoProvider));
            }

            OrderID             = order.OrderID;
            OrderInvoiceNumber  = order.OrderInvoiceNumber;
            OrderDate           = order.OrderDate;
            StatusName          = orderStatusInfoProvider.Get(order.OrderStatusID)?.StatusDisplayName;
            FormattedTotalPrice = String.Format(currencyInfoProvider.Get(order.OrderCurrencyID).CurrencyFormatString, order.OrderTotalPrice);
        }
Esempio n. 2
0
        public ActionResult OrderDetail(int?orderID)
        {
            if (orderID == null)
            {
                return(RedirectToAction("Index"));
            }

            var order = orderRepository.GetById(orderID.Value);

            if ((order == null) || (order.OrderCustomerID != CurrentCustomer?.CustomerID))
            {
                return(RedirectToAction("Error", "HttpErrors", new { code = (int)HttpStatusCode.NotFound }));
            }

            var currency = currencyInfoProvider.Get(order.OrderCurrencyID);

            return(View(new OrderDetailViewModel(currency.CurrencyFormatString)
            {
                InvoiceNumber = order.OrderInvoiceNumber,
                TotalPrice = order.OrderTotalPrice,
                StatusName = orderStatusInfoProvider.Get(order.OrderStatusID)?.StatusDisplayName,
                OrderAddress = new OrderAddressViewModel(order.OrderBillingAddress, countryInfoProvider, stateInfoProvider),
                OrderItems = OrderItemInfoProvider.GetOrderItems(order.OrderID).Select(orderItem =>
                {
                    return new OrderItemViewModel
                    {
                        SKUID = orderItem.OrderItemSKUID,
                        SKUName = orderItem.OrderItemSKUName,
                        SKUImagePath = string.IsNullOrEmpty(orderItem.OrderItemSKU.SKUImagePath) ? null : new FileUrl(orderItem.OrderItemSKU.SKUImagePath, true).WithSizeConstraint(SizeConstraint.MaxWidthOrHeight(70)).RelativePath,
                        TotalPriceInMainCurrency = orderItem.OrderItemTotalPriceInMainCurrency,
                        UnitCount = orderItem.OrderItemUnitCount,
                        UnitPrice = orderItem.OrderItemUnitPrice
                    };
                })
            }));
        }