Пример #1
0
 private CartItemOverviewModel BuildCartItemOverviewModel(CartItem item)
 {
     return(new CartItemOverviewModel
     {
         Id = item.Id,
         ProductId = item.ProductId,
         ProductPriceId = item.ProductPriceId,
         Name = item.Product.Name,
         Quantity = item.Quantity,
         OfferPriceExclTax = item.GetPrice(inclTax: false),
         OfferPriceInclTax = item.GetPrice(),
         PriceExclTax = item.ProductPrice.PriceExclTax,
         PriceInclTax = item.ProductPrice.PriceInclTax,
         Option = item.ProductPrice.Option,
         ThumbnailFilename = item.Product.ProductMedias.Count > 0 ? item.Product.ProductMedias[0].ThumbnailFilename : string.Empty,
         UrlKey = item.Product.UrlRewrite,
         StepQuantity = item.Product.StepQuantity,
         MaxAllowedQuantity = item.Product.IsPharmaceutical ? _shoppingCartSettings.MaxPharmaceuticalProduct : 10,
         IsPharmaceutical = item.Product.IsPharmaceutical,
         Discontinued = item.Product.Discontinued,
         BrandEnforcedStockCount = item.Product.Brand.EnforceStockCount,
         ProductEnforcedStockCount = item.Product.EnforceStockCount,
         Stock = item.ProductPrice.Stock,
         MaximumAllowedPurchaseQuantity = item.ProductPrice.MaximumAllowedPurchaseQuantity
     });
 }
Пример #2
0
        public void Testing_CartItem()
        {
            CartItem cartItem = new CartItem();

            cartItem.AddItem(clothShirt);
            cartItem.AddItem(clothShirt);
            cartItem.AddItem(clothJeans);
            Assert.Equal(1600, cartItem.GetPrice(clothShirt));
        }
Пример #3
0
        public void GetPrice(double expectedItemPrice, int quantity, double productPrice, int quantityPerPrice)
        {
            var item = new CartItem()
            {
                Quantity = quantity,
                Product  = new ProductEntity()
                {
                    Price            = productPrice,
                    QuantityPerPrice = quantityPerPrice
                }
            };

            item.GetPrice().Should().Be(expectedItemPrice);
        }
Пример #4
0
 public static LineItem ToLineItem(this CartItem cartItem, int orderId, string currencyCode, decimal exchangeRate, string lineStatus)
 {
     return(new LineItem
     {
         OrderId = orderId,
         ProductPriceId = cartItem.ProductPriceId,
         ProductId = cartItem.ProductId,
         Name = cartItem.Product.Name,
         Option = cartItem.ProductPrice.Option,
         PriceInclTax = cartItem.GetPrice(),
         PriceExclTax = cartItem.GetPrice(inclTax: false),
         InitialPriceInclTax = cartItem.ProductPrice.PriceInclTax,
         InitialPriceExclTax = cartItem.ProductPrice.PriceExclTax,
         Quantity = cartItem.Quantity,
         PendingQuantity = cartItem.Quantity,
         Wrapped = false,
         IsPharmaceutical = cartItem.Product.IsPharmaceutical,
         Weight = cartItem.ProductPrice.Weight,
         CostPrice = cartItem.ProductPrice.CostPrice,
         ExchangeRate = exchangeRate,
         CurrencyCode = currencyCode,
         StatusCode = lineStatus
     });
 }
Пример #5
0
    private void DisplayDetails()
    {
        if (Session["CART"] == null)
        {
            Response.Redirect("~/Home.aspx");
        }
        ArrayList arrCart = (ArrayList)Session["CART"];

        if (arrCart.Count == 0)
        {
            Response.Redirect("~/Home.aspx");
        }

        double totalCost = 0.0;

        pnlCartDetails.Controls.Clear();

        Table tblCartDetails = new Table();

        tblCartDetails.CssClass = "table";

        for (int loop = 0; loop < arrCart.Count; loop++)
        {
            CartItem cartItem = (CartItem)arrCart[loop];

            TableRow tr = new TableRow();
            tr.CssClass = "table-row";

            TableCell tc1 = new TableCell();
            tc1.CssClass = "table-cell";
            Image albumArt = new Image();
            albumArt.ImageUrl = "~/" + cartItem.GetAlbumArtPath();
            tc1.Controls.Add(albumArt);
            tr.Cells.Add(tc1);

            TableCell tc2 = new TableCell();
            tc2.CssClass = "table-cell";
            Label albumName = new Label();
            albumName.Text = cartItem.GetAlbumName();
            tc2.Controls.Add(albumName);
            tr.Cells.Add(tc2);

            TableCell tc3 = new TableCell();
            tc3.CssClass = "table-cell";
            Label price = new Label();
            price.Text = "£" + String.Format("{0:0.00}", cartItem.GetPrice());
            tc3.Controls.Add(price);
            tr.Cells.Add(tc3);

            TableCell tc4 = new TableCell();
            tc4.CssClass = "table-cell";
            Button btnRemove = new Button();
            btnRemove.ID     = loop.ToString();
            btnRemove.Text   = "Remove";
            btnRemove.Click += btnRemove_Click;
            tc4.Controls.Add(btnRemove);
            tr.Cells.Add(tc4);

            tblCartDetails.Rows.Add(tr);
            totalCost += cartItem.GetPrice();
        }

        pnlCartDetails.Controls.Add(tblCartDetails);
        lblCost.Text = "Total cost: £" + String.Format("{0:0.00}", totalCost);
    }