コード例 #1
0
        public IActionResult Detail(int id)
        {
            var asset = _assets.GetbyId(id);

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

            var model = new AssetDetailModel
            {
                AssetId          = id,
                Title            = asset.Title,
                Type             = _assets.GetType(id),
                Year             = asset.Year,
                Cost             = asset.Cost,
                Status           = asset.Status.Name,
                ImageUrl         = asset.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(id),
                CurrentLocation  = _assets.GetCurrentLocation(id).Name,
                DeweyCallNumber  = _assets.GetDeweyIndex(id),
                CheckoutHistory  = _checkouts.GetCheckoutHistory(id),
                ISBN             = _assets.GetIsbn(id),
                LatestCheckOut   = _checkouts.GetLatestCheckout(id),
                PatronName       = _checkouts.GetCurrentCheckoutPatron(id),
                CurrentHolds     = currentHolds
            };

            return(View(model));
        }