درود
ایراد بخاطر یه سری بی دقتی از جانب خودم بود که حل شد
اینام کدهای درست :
منو:
// بارگزاری پست ها براساس منو
[Route("{mnu}/{id}")]
public ActionResult GetMenu(int id,int page=1)
{
if (id==0)
{
ViewBag.Error = "نشانی درخواست شده یافت نشد!";
return View("~/Views/Home/ErrorPage.cshtml");
}
PostRepository rpPost = new PostRepository();
CommentRepository rpCmnt = new CommentRepository();
WmHomePage oModel = new WmHomePage();
List<Post> pst = rpPost.Select().ToList();
oModel.CarentPage = page;
oModel.posts = pst.Where(x => x.id_menu == id && x.Is_show==true).OrderByDescending(d => d.Date).ThenByDescending(t => t.Time).Skip((page - 1) * 10).Take(10).ToList();
oModel.TotalItemPost = oModel.posts.Where(x => x.Is_show == true).Count();
oModel.AtachPosts = pst.Where(x => x.FileName != "" && x.Is_show==true).OrderBy(d => d.Date).ThenBy(t => t.Time).Take(3).ToList();
oModel.TopViewPosts = pst.Where(x=>x.Is_show==true).OrderByDescending(s => s.Views).ThenByDescending(d => d.Date).ThenBy(t => t.Time).Take(4).ToList();
oModel.comments = rpCmnt.Where(x => x.Is_show == true).OrderBy(d => d.Date).ThenBy(t => t.Time).Take(5).ToList();
return View(oModel);
}
//--------------------------------
// بارگزاری پستها براساس زیر منو
[Route("{mnu}/{sb}/{id}")]
public ActionResult GetSubMenu(int id, int page=1)
<ul class="ul-main">
@foreach (var item in Model)
{
if (item.Parent == 0)
{
<li class="li-main">
<a href="@Url.Action("GetMenu", "Home", new { id = item.ID, mnu=item.Url }, null)"><i class="@item.Icon"></i> @item.Name </a>
<ul class="ul-sub">
@foreach (var sub in Model)
{
if (sub.Parent == item.ID)
{
<li class="li-sub">
<a href="@Url.Action("GetSubMenu", "Home", new { id = sub.ID,mnu=item.Url,sb=sub.Url }, null)">@sub.Name </a>
</li>
}
}
</ul>
</li>
}
}
</ul>
menu.png
پست:
//نمایش پست
[Route("{mnu}/{sb}/{ttl}/{id}")]
public ActionResult ShowPost(int id)
{
<h3>@Html.ActionLink(item.Tittle, "ShowPost", "Home", new { id = item.ID,ttl=item.Tittle,mnu=urlmnu,sb=urlsub },null)</h3>
post.png
فقط همینجور که می بینید توی یوآرال پست چون سرنام(عنوان) پست فارسی هست آی.دی پست قبل از سرنام درج شده.آیا راهی هست مانند ترتیبی که توی اکشن مشخص کردم آی.دی بعد از سرنام در یوآرال درج شه.(سرنام فارسی باشه)؟