public async Task<ActionResult> Reservations(Guid id)
        {
            var selectedBook = await _booksRepo.Get(id);
            var bookReservations = await _reservationsRepo.GetBookReservations(id);
            List<ReservationModel> bookReservationsModel = new List<ReservationModel>();
            
            foreach (var reservation in bookReservations)
            {
                var owner = await _userManager.FindByIdAsync(reservation.Owner);
                bookReservationsModel.Add(new ReservationModel()
                {
                    BookTitle = selectedBook.Title,
                    Owner = owner.UserName,
                    Date = reservation.Date
                });
            }

            ViewData["BookReservations"] = bookReservationsModel;

            return View(selectedBook);
        }
Esempio n. 2
0
        public async Task <IActionResult> Index()
        {
            var userReservations = await _reservationsRepo.GetUserReservations(_userManager.GetUserId(User));

            List <Book> userBooks = new List <Book>();

            foreach (var reservation in userReservations)
            {
                var book = await _booksRepo.Get(reservation.Book);

                userBooks.Add(book);
            }

            ViewData["Books"] = userBooks;

            return(View());
        }