public async Task <IActionResult> OnGet() { ViewModel = new BlogsViewModel(); ViewModel.Blogs = new List <Blog>(); ViewModel.Blogs = await _blogService.BlogsAsync(); return(Page()); }
public async Task <IActionResult> OnGet() { ViewModel = new BlogsViewModel { Blogs = await _blogServices.BlogsAsync() }; return(Page()); }
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)); }