Example #1
0
        public IActionResult Detail(int id)
        {
            var asset = _assets.GetAsset(id);

            var currentHolds = _checkout.GetCurrentHolds(id).Select(a => new AssetHoldModel
            {
                HoldPlaced = _checkout.GetCurrentHoldPlaced(a.Id).ToString("d"),
                PatronName = _checkout.GetCurrentHoldPatronName(a.Id)
            });

            var model = new AssetDetailModel
            {
                AssetId          = id,
                Title            = asset.Title,
                Type             = _assets.GetType(id),
                Year             = asset.Year,
                Cost             = asset.Cost,
                Isbn             = _assets.GetIsbn(id),
                Status           = asset.Status.Name,
                ImageUrl         = asset.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(id),
                CurrentLocation  = _assets.GetCurrentLocation(id)?.Name,
                Dewey            = _assets.GetDewyIndex(id),
                CheckoutHistory  = _checkout.GetCheckoutHistories(id),
                //   CurrentAssociatedLibraryCard = _ass,
                //  Isbn = _assets.GetIsbn(id),
                latestCheckout = _checkout.GetLatestCheckout(id),
                CurrentHolds   = currentHolds,
                PatronName     = _checkout.GetCurrentCheckoutPatron(id)
            };

            return(View(model));
        }
        public async Task <IActionResult> GetAsset(int id)
        {
            var asset = await _assets.GetAsset(id);

            var assetToReturn = _mapper.Map <AssetForDetailedDto>(asset);

            return(Ok(assetToReturn));


            //14:12 in video, detail.cshtml
        }