private static string GetMenuCats() { StringBuilder bld = new StringBuilder(); using (ZloContext cn = new ZloContext()) { foreach (var cat in cn.Categorys.OrderBy(c => c.Por)) { bld.AppendLine(string.Format(tmplC, cat.Title, GetPostInCat(cat))); } } return(bld.ToString()); }
private static string GetMenuPosts() { StringBuilder bld = new StringBuilder(); using (ZloContext cn = new ZloContext()) { IQueryable <Post> pst = cn.Posts.Where(p => p.CategoryId == null); foreach (var ps in pst) { bld.AppendLine(string.Format(tmplP, ps.WebLink, ps.Title)); } } return(bld.ToString()); }
private static string GetPostInCat(Category cat) { StringBuilder bld = new StringBuilder(); using (ZloContext cn = new ZloContext()) { List <Post> psts = cn.Posts.Where(p => p.CategoryId == cat.Id).Where(p => p.InCatMenu).ToList(); if (psts.Count > 0) { bld.AppendLine("<ul>"); foreach (var ps in psts) { bld.AppendLine(string.Format(tmplP, ps.WebLink, ps.Title)); } bld.AppendLine("</ul>"); } } return(bld.ToString()); }