in src/React.Sample.Mvc4/Controllers/HomeController.cs [86:109]
public ActionResult Comments(int page)
{
Response.Cache.SetOmitVaryStar(true);
var comments = _comments.Skip((page - 1) * COMMENTS_PER_PAGE).Take(COMMENTS_PER_PAGE);
var hasMore = page * COMMENTS_PER_PAGE < _comments.Count;
if (ControllerContext.HttpContext.Request.ContentType == "application/json")
{
return Json(new
{
comments = comments,
hasMore = hasMore
}, JsonRequestBehavior.AllowGet);
}
else
{
return View("Index", new IndexViewModel
{
Comments = _comments.Take(COMMENTS_PER_PAGE * page),
CommentsPerPage = COMMENTS_PER_PAGE,
Page = page
});
}
}