Esempio n. 1
0
        public IActionResult Detail(int id)
        {
            var book         = _books.GetById(id);
            var currentHolds = _rents.GetCurrentHolds(id)
                               .Select(a => new BookHoldModle
            {
                HoldPlaced = _rents.GetCurrentHoldPlaced(a.Id).ToString("d"),
                RenterName = _rents.GetCurrentHoldRenterName(a.Id)
            });

            var currentRenters = _rents.GetCurrentRenters(id)
                                 .Select(r => new CurrentRentersModel
            {
                RenterName = r.FirstName + " " + r.LastName
            });

            var model = new TextbookDetailModel
            {
                BookId           = id,
                Title            = book.Title,
                Cost             = book.Cost,
                Status           = book.Status.Name,
                ImageUrl         = book.ImageUrl,
                NumberOfCopies   = book.NumberOfCopies,
                NumberOfRentOuts = book.NumberOfRentOuts,
                CurrentHolds     = currentHolds,
                CurrentRenters   = currentRenters,
                RentHistory      = _rents.GetRentHistory(id)
            };

            return(View(model));
        }