Ejemplo n.º 1
0
        public async Task <IActionResult> OnGet()
        {
            ViewModel       = new BlogsViewModel();
            ViewModel.Blogs = new List <Blog>();
            ViewModel.Blogs = await _blogService.BlogsAsync();

            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnGet()
        {
            ViewModel = new BlogsViewModel
            {
                Blogs = await _blogServices.BlogsAsync()
            };

            return(Page());
        }
Ejemplo n.º 3
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            BlogsNavViewModel viewModel = new BlogsNavViewModel();

            viewModel.Blogs = new List <Blog>();

            var blogList = await _data.BlogsAsync();

            int i = 1;

            foreach (var item in blogList)
            {
                if (i <= 4)
                {
                    viewModel.Blogs.Add(item);
                }

                i++;
            }

            viewModel.Total = blogList.Count;

            return(View(viewModel));
        }