public ActionResult Video()
 {
     MyViewModel vm = new MyViewModel();
     ViewBag.Message = "Make-up tutorials";
     List<Video> videos = db.Videos.ToList();
     vm.VMVideo = videos;
     return View(vm);
 }
 public ActionResult Blog()
 {
     MyViewModel vm = new MyViewModel();
     ViewBag.Message = "Nyeste blogindlæg";
     List<Blog> blogs = db.Blogs.ToList();
     vm.VMBlog = blogs;
     return View(vm);
 }
 public ActionResult Products()
 {
     ShoppingCartId = GetCartId();
     MyViewModel vm = new MyViewModel();
     List<Product> products = db.Products.ToList();
     vm.VMProduct = products;
     List<int> amountList = new List<int>();
     IEnumerable<ShoppingCart> carts = db.ShoppingCarts.Where(x => x.OrderNumber.Equals(ShoppingCartId));
     foreach (var item in carts)
     {
         amountList.Add(item.Amount);
     }
     ViewBag.Amount = amountList.Sum();
     return View(vm);
 }
        public ActionResult Index()
        {
            Response.AppendHeader("Index","< meta http - equiv = 'X-UA-Compatible' content = 'IE=EmulateIE9' >");
            MyViewModel vm = new MyViewModel();
            List<Blog> blogList = new List<Blog>();
            List<Product> productList = new List<Product>();
            List<Video> videoList = new List<Video>();
            Blog lastBlog = db.Blogs.ToList().Last();
            Product lastProduct = db.Products.ToList().Last();
            Video lastVideo = db.Videos.ToList().Last();
            blogList.Add(lastBlog);
            productList.Add(lastProduct);
            videoList.Add(lastVideo);
            vm.VMBlog = blogList;
            vm.VMProduct = productList;
            vm.VMVideo = videoList;

            return View(vm);            
        }
        public ActionResult Create([Bind(Include = "Id,TotalSum,Name,Address,PhoneNumber,Email,City,ZipCode,OrderNumber,CardNumber,Date,CVR")] Order order)
        {
            MyViewModel vm = new MyViewModel();
            ShoppingCartId = GetCartId();
            List<Product> productList = new List<Product>();
            List<double> ListSum = new List<double>();
            IEnumerable<ShoppingCart> cartList = new List<ShoppingCart>();
            cartList = db.ShoppingCarts.Where(x => x.OrderNumber.Equals(ShoppingCartId));
            foreach (var item in cartList)
            {
                Product product = db.Products.Find(item.ProductId);
                productList.Add(product);
                int productStock = product.Stock;
                int cartAmount = item.Amount;
                product.Stock.Equals(productStock - cartAmount);
                double multipliedSum = product.Price * item.Amount;
                ListSum.Add(multipliedSum);
            }

            double total = ListSum.Sum();
            order.TotalSum = total;
            order.OrderNumber = ShoppingCartId;
            order.Date = DateTime.Today;                      
            

            db.Orders.Add(order);
            db.SaveChanges();        
                
            IEnumerable<Order> orderList = db.Orders.Where(x => x.OrderNumber.Equals(ShoppingCartId));
            vm.VMOrder = orderList;
            vm.VMProduct = productList;
            vm.VMCart = cartList;
               

            return View("OrderView", vm);
        }
        public ActionResult ShoppingCart()
        {
            ShoppingCartId = GetCartId();
            MyViewModel vm = new MyViewModel();

            List<Product> products = new List<Product>();
            List<ShoppingCart> cartList = db.ShoppingCarts.Where(x => x.OrderNumber.Equals(ShoppingCartId)).ToList();
            List<int> cartAmountList = new List<int>();
            List<double> ListSum = new List<double>();
            foreach (var item in cartList)
            {
                Product product = db.Products.Find(item.ProductId);
                products.Add(product);
                double multipliedSum = product.Price * item.Amount;
                ListSum.Add(multipliedSum);
            }
           
            vm.VMProduct = products;
            vm.VMCart = cartList;
            ViewBag.Sum = ListSum.Sum();
            return View(vm);
        }