Ejemplo n.º 1
0
        public ActionResult LogIn(Customer loggedInCustomer)
        {
            customer = context.customers.Where(c => c.Username == loggedInCustomer.Username && c.Password == loggedInCustomer.Password).FirstOrDefault();


            //explicit loading
            context.Entry(customer).Collection(c => c.Bookings).Load();


            List <SelectListItem> selectListItems = new List <SelectListItem>();


            foreach (Booking booking in customer.Bookings)
            {
                //explicit loading
                context.Entry(booking).Reference(b => b.Tool).Load();
                SelectListItem selectListItem = new SelectListItem()
                {
                    Text  = booking.Tool.ToString(),
                    Value = booking.bookingId.ToString()
                };


                selectListItems.Add(selectListItem);
            }

            ViewBag.Bookings = new SelectList(selectListItems, "Value", "Text");

            BookingViewModel bvm = new BookingViewModel()
            {
                Bookings = selectListItems
            };

            return(View("LogInDetails", bvm));
        }
        private void SelectedCustomerLoad()
        {
            tbName.DataContext    = _selectedCustomer;
            tbAddress.DataContext = _selectedCustomer;
            tbEmail.DataContext   = _selectedCustomer;



            //Explict loading
            foreach (Booking booking in _selectedCustomer.Bookings)
            {
                _context.Entry(booking).Reference(b => b.Tool).Load();
            }



            ListBookings.ItemsSource = _selectedCustomer.Bookings;

            ListBookings.Items.Refresh();
        }