this is the Controller:
and this my route i want add title of news after id
for example:news/55/مایکروسافت،سرفیس دو
[Route("News/{id}")]
public ActionResult ShowNews(int id)
{
var news = pageRepository.GetPageById(id);
if (news == null)
{
return HttpNotFound();
}
news.Visit += 1;
pageRepository.UpdatePage(news);
pageRepository.Save();
return View(news);
}
this is the page Repository:
private MyCmsContext db;
public PageRepository(MyCmsContext context)
{
this.db = context;
}
public IEnumerable<Page> GetAllPage()
{
return db.Pages;
}
public Page GetPageById(int pageId)
{
return db.Pages.Find(pageId);
}
this is the Interface page Repository:
IEnumerable<Page> GetAllPage();
Page GetPageById(int pageId);
bool InsertPage(Page page);
bool UpdatePage(Page page);
bool DeletePage(Page page);
bool DeletePage(int pageId);
void Save();