public ActionResult buy(int userID, double total) //Action to get the details of the customers

        {
            ViewBag.email = context.userDatas.Find(userID).email;

            ViewBag.userId = userID;
            ViewBag.Total  = total;


            var bookingdateviewmodel = new BookingDateViewModel();



            bookingdateviewmodel.timeViewModel = context.times.ToList();


            return(View(bookingdateviewmodel));
        }
        public ActionResult buy(BookingDateViewModel data)     //Action to complete payment and save billing details in the database tables
        {
            data.bookingViewModel.BookingDate = DateTime.Now;  //Saving timing of payment
            data.bookingViewModel.Status      = "Not shipped"; //initial delivery status



            context.bookings.Add(data.bookingViewModel);  //adding payment details in database

            context.SaveChanges();
            var bookid = data.bookingViewModel.BookingId;


            var bookedItems = new BookedItems();


            var cartItem = context.carts.ToList();

            foreach (var item in cartItem)
            {
                var quantitysub = context.products.Find(item.productId).Quantity - item.Quantity;
                context.products.Find(item.productId).Quantity = quantitysub;


                bookedItems.productId   = item.productId;
                bookedItems.productName = item.productName;
                bookedItems.Price       = item.price;
                bookedItems.Quantity    = item.Quantity;
                bookedItems.totalPrice  = item.totalPrice;
                bookedItems.bookingId   = bookid;
                context.bookedItems.Add(bookedItems);
                context.SaveChanges();
            }

            context.carts.RemoveRange(context.carts.ToList());

            context.SaveChanges();



            return(RedirectToAction("dashboard", "shopping", new { userId = data.bookingViewModel.userId })); //redirecting to customer database
        }