public ActionResult Render()
        {
            var miniBasketViewModel = new MiniBasketViewModel();

            if (!TransactionLibrary.HasBasket())
            {
                miniBasketViewModel.Empty = true;

                return(View("/views/Minibasket/index.cshtml", miniBasketViewModel));
            }

            var basket = TransactionLibrary.GetBasket(false);

            miniBasketViewModel.Empty       = false;
            miniBasketViewModel.OrderTotal  = new Money(basket.OrderTotal.GetValueOrDefault(0), basket.BillingCurrency.ISOCode).ToString();
            miniBasketViewModel.ItemsInCart = basket.OrderLines.Sum(x => x.Quantity);
            return(View("/views/Minibasket/index.cshtml", miniBasketViewModel));
        }
示例#2
0
// GET: MiniBasket
        public ActionResult Index()
        {
            var miniBasket = new MiniBasketViewModel();

            miniBasket.IsEmpty = true;

            if (TransactionLibrary.HasBasket())
            {
                PurchaseOrder basket        = TransactionLibrary.GetBasket(false).PurchaseOrder;
                var           numberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                if (numberOfItems != 0)
                {
                    miniBasket.Total         = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency);
                    miniBasket.NumberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                    miniBasket.IsEmpty       = false;
                }
            }
            return(View("/Views/PartialView/MiniBasket.cshtml", miniBasket));
        }
示例#3
0
// GET: MiniBasket
        public ActionResult Index()
        {
            var miniBasket = new MiniBasketViewModel();

            miniBasket.IsEmpty = true;

            if (TransactionLibrary.HasBasket())
            {
                PurchaseOrder basket = TransactionLibrary.GetBasket(false).PurchaseOrder;

                var numberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                if (numberOfItems != 0)
                {
                    foreach (var orderLine in basket.OrderLines)
                    {
                        var miniOrderLineViewModel = new MiniOrderlineViewModel
                        {
                            Quantity          = orderLine.Quantity,
                            ProductName       = orderLine.ProductName,
                            Sku               = orderLine.Sku,
                            VariantSku        = orderLine.VariantSku,
                            Total             = new Money(orderLine.Total.GetValueOrDefault(), basket.BillingCurrency).ToString(),
                            Discount          = orderLine.Discount,
                            Tax               = new Money(orderLine.VAT, basket.BillingCurrency).ToString(),
                            Price             = new Money(orderLine.Price, basket.BillingCurrency).ToString(),
                            ProductUrl        = CatalogLibrary.GetNiceUrlForProduct(CatalogLibrary.GetProduct(orderLine.Sku)),
                            PriceWithDiscount = new Money(orderLine.Price - orderLine.UnitDiscount.GetValueOrDefault(), basket.BillingCurrency).ToString(),
                            OrderLineId       = orderLine.OrderLineId
                        };


                        miniBasket.MiniOrderlineViewModelCollection.Add(miniOrderLineViewModel);
                    }

                    miniBasket.Total         = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency);
                    miniBasket.NumberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                    miniBasket.IsEmpty       = false;
                }
            }
            return(View("/Views/PartialView/MiniBasket.cshtml", miniBasket));
        }