internal static void UppdateMiniCart(MasterPage master, ShopingCart shopingCart)
        {
            var activeCart = shopingCart.CartItems.Take(shopingCart.ItemsInMiniCartToShow);

            Repeater shopingBasketRepeater = (Repeater)master.FindControl("repBasket");
            HyperLink linkToRegisterSmallCart = (HyperLink) master.FindControl("linkToRegisterSmallCart");
            Label lblMiniCartCount = (Label)master.FindControl("lblMiniCartCount");
            Label lblMiniCartSum = (Label)master.FindControl("lblMiniCartSum");
            Literal liMiniCartContentEmpty = (Literal)master.FindControl("liMiniCartContentEmpty");
            Label lblMoreThanFiveItemsInCart = (Label) master.FindControl("lblMoreThanFiveItemsInCart");

            lblMiniCartCount.Text = $"Articles: {shopingCart.NumberOfItems}"; ;
            lblMiniCartSum.Text = $"Sum: {shopingCart.SumTotal:N2} kr";

            shopingBasketRepeater.DataSource = activeCart;
            shopingBasketRepeater.DataBind();
            
            if (shopingCart.CartItems.Count > 0)
            {
                linkToRegisterSmallCart.Visible = true;
                liMiniCartContentEmpty.Visible = false;
            }
            else
            {
                linkToRegisterSmallCart.Visible = false;
                liMiniCartContentEmpty.Visible = true;
            }

            if (shopingCart.CartItems.Count > shopingCart.ItemsInMiniCartToShow)
                lblMoreThanFiveItemsInCart.Visible = true;
            else
            {
                lblMoreThanFiveItemsInCart.Visible = false;
            }
        }
        private void FillCartItemsAndPrice(ShopingCart shopingCart)
        {

            if (shopingCart != null && shopingCart.CartItems.Count > 0)
            {
                repBasket.DataSource = shopingCart.CartItems;
                repBasket.DataBind();

                LtCartSum.Text = $"{shopingCart.SumTotal:N2}";

                var sumWithFreigth = shopingCart.SumTotal + GetFreightPrice();

                ltTotalPriceWithFreight.Text = $"{sumWithFreigth:N2}";

            panelBasketWIthItems.Visible = true;
                panelRegister.Visible = true;

                panelBasketEmpty.Visible = false;
            }
            else
            {
                panelBasketEmpty.Visible = true;

                panelBasketWIthItems.Visible = false;
                panelRegister.Visible = false;
            }
        }
        internal static bool AddOrUpdateProductToCart(ref ShopingCart cart, int productID, short productQty, bool replaceQuantity = false)
        {
            using (var db = new AvensiaWebshopEntities())
            {
                var vProduct = db.vProductAndDescripttionExtendedENOnly.FirstOrDefault(p => p.ProductID == productID);

                if (vProduct == null)
                {
                    // TODO: Implementera felkod om Product är null (inte finns i database).
                    return false;
                }

                var cartItem = cart.CartItems.FirstOrDefault(i => i.ProductID == vProduct.ProductID);
                
                if (cartItem == null)
                {
                    cartItem = new CartItem()
                    {
                        ProductID = vProduct.ProductID,
                        ProductModelID = vProduct.ProductModelID,
                        ProductName = vProduct.Name,
                        ProductImage = vProduct.LargePhotoFileName,
                        Price = Math.Round(WebShopController.GetProductPrice(vProduct), 2),
                        Quantity = 0,
                        Dricounted = vProduct.DiscountActive ?? false,
                        OriginalPrice = Math.Round(vProduct.ListPrice, 2)
                    };

                    cart.CartItems.Insert(0, cartItem);
                }

                if (replaceQuantity)
                    cartItem.Quantity = productQty;
                else
                    cartItem.Quantity += productQty;
            }

            return true;
        }
        internal static bool RemoveProductFromCart(ref ShopingCart cart, int productID)
        {
            var cartItem = cart.CartItems.SingleOrDefault(i => i.ProductID == productID);

            return cart.CartItems.Remove(cartItem);
        }
        private void UppdateCartAndSession(ShopingCart shopingCart)
        {
            Session[WebShopController.SessionKeyShopingCart] = shopingCart;

            FillCartItemsAndPrice(shopingCart);

            WebShopController.UppdateMiniCart(Master, shopingCart);
        }
        protected void btnAddToCart_Click(object sender, EventArgs e)
        {
            ShopingCart shopingCart = (ShopingCart)Session[WebShopController.SessionKeyShopingCart];

            if (shopingCart == null)
                shopingCart = new ShopingCart();

            int productID = -1;
            if (!int.TryParse(hfActiveProduct.Value, out productID))
            {
                // TODO: Implementera felkod om ProductID inte är en sifra (HidenField går inte att manupura på framsidan(?)).
            }

            short productQty;
            if (!short.TryParse(txtArticleAmount.Text, out productQty))
            {
                // TODO: Implementera felkod om antalet inte är en sifra.
            }

            if (WebShopController.AddOrUpdateProductToCart(ref shopingCart, productID, productQty))
            {
                //TODO: Implementera felkod om varan inte kan läggas i korgen.
            }

            Session[WebShopController.SessionKeyShopingCart] = shopingCart;

            WebShopController.UppdateMiniCart(Master, shopingCart);
        }