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(); }
public User ValidateUser(string userName, string password) { string hash = Hash.CreateHash(password); using (ZloContext cont = new ZloContext()) { return(cont.Users .Where(u => u.Login == userName) .Where(u => u.PassWord == hash).FirstOrDefault()); } }
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(); }
public User ValidateUser(string userName, string password) { string hash = Hash.CreateHash(password); using (ZloContext cont = new ZloContext()) { return cont.Users .Where(u => u.Login == userName) .Where(u => u.PassWord == hash).FirstOrDefault(); } }