コード例 #1
0
        public IActionResult Detail(int id)
        {
            var asset        = _asset.GetById(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             = _asset.GetType(id),
                Year             = asset.Year,
                Cost             = asset.Cost,
                Status           = asset.Status.Name,
                ImageUrl         = asset.ImageUrl,
                AuthorOrDirector = _asset.GetAuthorOrDirector(id),
                CurrentLocation  = _asset.GetCurrrentLocation(id).Name,
                Dewey            = _asset.GetDeweyIndex(id),
                CheckoutHistory  = _checkout.GetCheckoutHistory(id),
                ISBN             = _asset.GetIsbn(id),
                LatestCheckout   = _checkout.GetLatestCheckout(id),
                PatronName       = _checkout.GetCurrentCheckoutPatron(id),
                CurrentHold      = currentHolds,
            };

            return(View(model));
        }