Exemplo n.º 1
0
        /*public IActionResult Detail(int id)
         * {
         *  var asset = _assets.GetById(id);
         *
         *  var model = new AssetDetailModel
         *  {
         *      AssetId = id,
         *      Title = asset.Title,
         *      Year = asset.Year,
         *      Cost = asset.Cost,
         *      Status = asset.Status.Name,
         *      ImgUrl = asset.ImageUrl,
         *      AuthorOrDirector = _assets.GetAuthorOrDirector(id),
         *      CurentLocation = _assets.GetCurrentLocation(id).Name,
         *      DeweyCallNumber = _assets.GetDeweyIndex(id),
         *      ISBN = _assets.GetISBM(id)
         *  };
         *  return View(model);
         * } */

        public IActionResult Detail(int id)
        {
            var asset = _assets.GetById(id);

            var currentHolds = _checkouts.GetCurrentHolds(id)
                               .Select(x => new AssetHoldModel
            {
                HoldPlaced = _checkouts.GetCurrentHoldPlaced(x.Id),
                PatronName = _checkouts.GetCurrentPatron(x.Id)
            });

            var model = new AssetDetailModel
            {
                AssetId          = id,
                Title            = asset.Title,
                Type             = _assets.GetType(id),
                Year             = asset.Year,
                Cost             = asset.Cost,
                Status           = asset.Status.Name,
                ImgUrl           = asset.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(id),
                CurentLocation   = _assets.GetCurrentLocation(id).Name,
                DeweyCallNumber  = _assets.GetDeweyIndex(id),
                CheckOutHistory  = _checkouts.GetCheckoutHistory(id),
                ISBN             = _assets.GetISBM(id),
                LatestCheckout   = _checkouts.GetLatestCheckout(id),
                PatroName        = _checkouts.GetCurrentCheckoutPatron(id),
                CurrentHolds     = currentHolds
            };


            return(View(model));
        }