// User View for their cart
        public ActionResult ViewCart(int iUserID)
        {
            // Must be logged in to any role to access this view
            if (((LoginModel)Session["loginModel"]) != null)
            {
                // Collect users parts in their Cart by using user ID
                ViewCartBLL viewCartBLL     = new ViewCartBLL();
                List <Part> listPartsInCart = viewCartBLL.GetPartsInCart(iUserID);

                // Create instance of CartModel
                CartModel cm = new CartModel();

                // Calculate sub total price with list of Parts
                // Calulate sales tax total by multiplying tax rate to sub total
                // Add tax and sub total to calculate Cart total
                cm.CartSubtotal = viewCartBLL.GetCartSubtotal(listPartsInCart);
                cm.TaxTotal     = viewCartBLL.GetCartTaxTotal(cm.CartSubtotal);
                cm.CartTotal    = viewCartBLL.GetCartTotal(cm.TaxTotal, cm.CartSubtotal);

                // Add listPartsInCart to CartModel
                cm.PartList = listPartsInCart;

                return(View(cm));
            }
            else
            {
                return(RedirectToAction("login", "home"));
            }
        }
        public void Test_Calculate_TaxTotal()
        {
            // Arrange
            List <Part> listPart = new List <Part>();

            Part part1 = new Part {
                Price = Convert.ToDecimal(100.50), PartQuantity = 2
            };

            listPart.Add(part1);

            Part part2 = new Part {
                Price = Convert.ToDecimal(10), PartQuantity = 1
            };

            listPart.Add(part2);

            Part part3 = new Part {
                Price = Convert.ToDecimal(25.25), PartQuantity = 4
            };

            listPart.Add(part3);

            ViewCartBLL viewCartBLL = new ViewCartBLL();


            // Act
            decimal subTotal = viewCartBLL.GetCartSubtotal(listPart);
            decimal actual   = viewCartBLL.GetCartTaxTotal(subTotal);

            decimal expect = Convert.ToDecimal(23.4);

            // Assert
            Assert.AreEqual(expect, actual);
        }