Exemplo n.º 1
0
        public ActionResult TravelProducts()
        {
            string userId = User.Identity.GetUserId();
            TravelProductViewModel viewModel = _context.GetCustomerTravelProducts(userId);

            if (viewModel.GetBookingCountWithPackage() == 0)
            {
                viewModel.Bookings = new List <Booking>();
            }

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public TravelProductViewModel GetCustomerTravelProducts(string userId)
        {
            var result = _context.Customers
                         .Include(b => b.Bookings).SingleOrDefault(b => b.UserId == userId);
            TravelProductViewModel travelProducts = new TravelProductViewModel();

            if (result != null)
            {
                travelProducts = new TravelProductViewModel
                {
                    CustomerId    = result.CustomerId,
                    CustFirstName = result.CustFirstName,
                    CustLastName  = result.CustLastName,
                    Bookings      = result.Bookings.ToList()
                };
            }

            return(travelProducts);
        }