public ViewResult Index()
        {
            var tours = _tourCart.GetShoppedTours();

            _tourCart.ShoppedTours = tours;

            var cartViewModel = new TourCartViewModel
            {
                TourCart  = _tourCart,
                CartTotal = _tourCart.GetCartTotal()
            };

            return(View(cartViewModel));
        }
Esempio n. 2
0
        public IActionResult CheckOut(Order order)
        {
            var tours = _tourCart.GetShoppedTours();

            _tourCart.ShoppedTours = tours;

            if (_tourCart.ShoppedTours.Count == 0)
            {
                ModelState.AddModelError("", "No tours in your cart. Please select some before your check out");
            }

            if (ModelState.IsValid)
            {
                _orderRepository.AddOrder(order);
                _tourCart.ClearCart();
                return(RedirectToAction("PostCheckOut"));
            }
            return(View(order));
        }
Esempio n. 3
0
        public IViewComponentResult Invoke()
        {
            var tours = _tourCart.GetShoppedTours();

            //mock data
            // var tours = new List<ShoppedTour>()
            //             {
            //                 new ShoppedTour(),
            //                 new ShoppedTour()
            //             };
            _tourCart.ShoppedTours = tours;

            var tourCartViewModel = new TourCartViewModel
            {
                TourCart  = _tourCart,
                CartTotal = _tourCart.GetCartTotal()
            };

            return(View(tourCartViewModel));
        }