Beispiel #1
0
        //Ação do controller para www.site.com.br/Catalog/Index
        //Deve retornar uma lista inteira do catalogo

        public IActionResult Index()
        {
            //Consulta feita na base
            var assetModels = _assets.GetAll();

            //Filtrar o que será visualizado na View
            var ListingResult = assetModels.Select(result => new AssetIndexListingModel
            {
                //Passar para o construtor os parâmetros que queremos ver na View
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDewayIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id)
            });;

            //Cria o modelo, baseado nos dados que foram consultados
            var model = new AssetIndexModel()
            {
                Assets = ListingResult
            };

            //retorna o modelo criado para a View Catalog
            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));
        }
        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));
        }