Get latest post and display on homepage
This commit is contained in:
parent
9e35d0ab90
commit
15b01412f2
3 changed files with 36 additions and 4 deletions
|
@ -4,15 +4,24 @@ using System.Diagnostics;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Website.Data;
|
||||
using Website.ViewModels;
|
||||
|
||||
namespace Website.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
private readonly BlogRepository _blogRepo;
|
||||
|
||||
public HomeController(BlogRepository blogRepo)
|
||||
{
|
||||
return View();
|
||||
_blogRepo = blogRepo;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var post = await _blogRepo.GetLatestPostAsync();
|
||||
return View(post);
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue