public JsonResult CategoryDelete(int id) { JsonResult rez = new JsonResult(); Category cat = new Category() { Id = id }; con.Entry(cat).State = System.Data.EntityState.Deleted; con.SaveChanges(); MenuHelper.UpdateCache(); rez.Data = "Категория меню удалена.;true"; return rez; }
public JsonResult Category(Category cat) { JsonResult rez = new JsonResult(); if (cat.Id == 0) { con.Categorys.Add(cat); rez.Data = RenderPartialViewToString("CategoryRow", cat); } else { con.Entry(cat).State = System.Data.EntityState.Modified; rez.Data = "Внесены изменения в категорию."; } con.SaveChanges(); MenuHelper.UpdateCache(); return rez; }
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 JsonResult CategoryForm(Category cat) { JsonResult rez = new JsonResult(); rez.Data = RenderPartialViewToString("Category", cat); return rez; }