Speaking of which, we haven't put in something that enables us to actually see the article with the full body, and so on. Let's just quickly do this.
Add a new Controller
class called ArticleController
. As we only need one action in it, enter the following code:
using System.Web.Mvc; using Chapter3.DAL; namespace Chapter3.Controllers { public class ArticleController : Controller { // GET: Article public ActionResult Full(int id) { using( var articleContext = new ArticleContext() ) { var article = articleContext.GetArticle(id); return View(article); } } } }
The action takes the identifier as an argument and uses it when calling GetArticle()
on ArticleContext
. This gets the specific article that we will use as a ViewModel for the page.