コード例 #1
0
 public OrderViewModel(OrderInfo order, ICurrencyInfoProvider currencyInfoProvider)
 {
     OrderID                = order.OrderID;
     OrderStatusID          = order.OrderStatusID;
     CurrencyFormatString   = currencyInfoProvider.Get(order.OrderCurrencyID).CurrencyFormatString;
     OrderDate              = order.OrderDate;
     OrderTotalPrice        = order.OrderTotalPrice;
     OrderIsPaid            = order.OrderIsPaid;
     OrderStatusDisplayName = OrderStatusInfo.Provider.Get(order.OrderStatusID)?.StatusDisplayName;
     if (order.OrderPaymentResult != null)
     {
         OrderPaymentResult = new OrderPaymentResultViewModel()
         {
             PaymentMethodName  = order.OrderPaymentResult.PaymentMethodName,
             PaymentIsCompleted = order.OrderPaymentResult.PaymentIsCompleted
         };
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
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
                    };
                })
            }));
        }