public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
ViewBag.Message = "Hello MVC";
return View();
}
}
@{
ViewBag.Title = "Index";
}
<h2>@ViewBag.Message</h2>
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
ViewBag.Message = "Hello MVC";
var books = (new BookStoreDBEntities()).Books.ToList();
return View(books);
}
}
@model List<global::MvcApplication.Models.Book>
@{
ViewBag.Title = "Index";
}
<h2>@ViewBag.Message</h2>
<table class="table">
@foreach (var book in Model)
{
<tr>
<td>@book.Id</td>
<td>@book.Title</td>
<td>@book.Author</td>
<td>@book.Price</td>
<td>@book.PubDate</td>
<td>@book.Category.Name</td>
</tr>
}
</table>