Esempio n. 1
0
        //GET Rentals/Book
        public async Task <IActionResult> Book(int id)
        {
            ApplicationUser appUser = await GetCurrentUserAsync();

            List <User> users = await _context.User.ToListAsync();

            Rentals rentals = await _context.Rentals.FirstOrDefaultAsync(r => r.Id == id);

            RentalVM vm = new RentalVM()
            {
                //Get Rentals to display Name, Location for View
                Rentals     = await _context.Rentals.FirstOrDefaultAsync(r => r.Id == id),
                UserOptions = users.Where(u => u.ApplicationUserId == appUser.Id && u.isArchived == false).Select(u => new SelectListItem
                {
                    Value = u.Id.ToString(),
                    Text  = u.FirstName
                })
                              .ToList()
            };

            vm.UserOptions.Insert(0, new SelectListItem
            {
                Text  = "Choose a User",
                Value = "0"
            });

            return(View(vm));
        }