Add BlogPostViewModel for view specific processing

This commit is contained in:
Robert Marshall 2019-04-28 07:56:25 +01:00
parent 647696aa92
commit dda522d221
6 changed files with 34 additions and 18 deletions

View file

@ -26,7 +26,8 @@ namespace Website.Controllers
public async Task<IActionResult> View(int id)
{
var post = await _repo.GetPostAsync(id);
return View(post);
var model = new BlogPostViewModel(post);
return View(model);
}
}
}

View file

@ -18,7 +18,8 @@ namespace Website.Controllers
public async Task<IActionResult> Index()
{
var post = await _blogRepo.GetLatestPostAsync();
return View(post);
var model = new BlogPostViewModel(post);
return View(model);
}
}
}