Exemplo n.º 1
0
        public IActionResult Detail(int id)
        {
            var asset = _assets.GetById(id);


            IEnumerable <AssetHoldModel> currentHolds = _checkout.GetCurrentHolds(id)
                                                        .Select(x => new AssetHoldModel
            {
                PatronName    = _checkout.GetPatronName(x.LibraryCard.Id).ToString(),
                HoldPlaced    = x.HoldPlaced,
                LibraryCardId = x.LibraryCard.Id
            });

            IEnumerable <CheckoutHistoryModel> checkoutHistories = _checkout.CheckoutHistory(asset.Id)
                                                                   .Select(x => new CheckoutHistoryModel
            {
                PatronName  = _checkout.GetPatronName(x.LibraryCard.Id).ToString(),
                CheckIn     = x.CheckIn,
                Checkout    = x.CheckOut,
                LibraryCard = x.LibraryCard
            });


            var displayAsset = new AssetDetailModel
            {
                Id                = asset.Id,
                PatronName        = _checkout.GetPatronName(4).FirstName,
                ImageUrl          = asset.ImgUrl,
                Title             = asset.Title,
                Year              = asset.Year,
                Cost              = asset.Cost,
                Status            = _assets.GetStatus(asset.Id).Name,
                AuthorOrDirector  = _assets.GetAuthorOrDirector(asset.Id),
                DeweyIndex        = _assets.GetDeweyIndex(asset.Id),
                NumberOfCopies    = asset.NumberOfCopies,
                Type              = _assets.GetType(asset.Id),
                CurrentLocation   = _assets.GetLocation(asset.Id).Name,
                ISBN              = _assets.GetISBN(id),
                CheckoutHistories = checkoutHistories,
                CurrentHolds      = currentHolds
            };

            return(View(displayAsset));
        }