public IActionResult Index()
        {
            var assetModels           = _assets.GetAll();
            AssetIndexListingModel dd = new AssetIndexListingModel();

            var listingResult = assetModels.Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = "img/13.jpg",
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                Title            = _assets.GetTitle(result.Id),
                Type             = _assets.GetType(result.Id),
                DeweyCallNumber  = _assets.GetDewayIndex(result.Id)
            });


            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels = _assets.GetAll();

            //use AutoMapper later to refactor code
            var listingResult = assetModels
                                .Select(r => new AssetIndexListingModel
            {
                Id               = r.Id,
                ImageUrl         = r.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(r.Id),
                DeweyCallNumber  = _assets.GetDewayIndex(r.Id),
                Title            = r.Title,
                Type             = _assets.GetType(r.Id)
            });

            var vm = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(vm));
        }
Пример #3
0
        public IActionResult Index()
        {
            //Gets list of all assets
            var assetModels = _assets.GetAll();
            //Stores list of assets in to a model, displaying select fields
            var listingResult = assetModels.Select(result => new AssetsIndexListingModel
            {
                Id              = result.Id,
                ImageUrl        = result.ImageUrl,
                AuthOrDirector  = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber = _assets.GetDeweyIndex(result.Id),
                Title           = result.Title,
                Type            = _assets.GetType(result.Id)
            });

            //Creates a separate model for the index, assigns the above view model to this view model, allows for more modularity and a layer of abstraction
            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            //returns the index model
            return(View(model));
        }