public JsonResult GetNews_type(int id) { B_News_type b_nt = new B_News_type(); var res = b_nt.Get(id); return(Json(res)); }
public JsonResult DelNews_type(string ids) { Common.Json json = new Common.Json(); B_News_type b_nt = new B_News_type(); foreach (var id in ids.Split(new char[] { ',' })) { b_nt.Delete(Convert.ToInt32(id)); } json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "条记录!"; return(Json(json)); }
public static string select_new_type(this HtmlHelper helper) { B_News_type b_nt = new B_News_type(); List <Order> order = new List <Order>() { Order.Asc("sort_id") }; List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "parent_id", value = 0, searchType = Common.EnumBase.SearchType.Eq } }; var list_nt = b_nt.GetList(st, order); StringBuilder sb = new StringBuilder(); sb.Append("<select id=\"txt_parent_id\" name=\"txt_parent_id\" class=\"selectpicker show-tick form-control\" data-live-search=\"true\">"); sb.Append("<optgroup label=\"一级菜单\">"); sb.Append("<option data-subtext=\"一级菜单\" selected = \"true\">0</option>"); sb.Append("</optgroup>"); foreach (var item in list_nt) { sb.Append("<optgroup label=" + item.title + ">"); sb.Append("<option data-subtext=" + item.title + ">" + item.id + "</option>"); //一级菜单放第一个 st = new List <SearchTemplate>() { new SearchTemplate() { key = "parent_id", value = item.id, searchType = Common.EnumBase.SearchType.Eq } }; //var list_subnt = b_nt.GetList(st, order); //foreach (var sub in list_subnt) //{ // sb.Append("<option data-subtext=" + sub.title + ">" + sub.id + "</option>"); //二级菜单 //} sb.Append("</optgroup>"); } sb.Append("</select>"); return(sb.ToString()); }
public JsonResult GetNews_typeList(int limit = 10, int offset = 1) { B_News_type b_nt = new B_News_type(); List <Order> order = new List <Order>() { Order.Asc("id") }; List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "parent_id", value = 0, searchType = EnumBase.SearchType.Eq }, new SearchTemplate() { key = "", value = new int[] { offset, limit }, searchType = Common.EnumBase.SearchType.Paging } }; List <Domain.News_type> list = new List <Domain.News_type>(); var list_nt = b_nt.GetList(st, order); var list_nt_count = b_nt.GetCount(st); foreach (var item in list_nt) { list.Add(item); st = new List <SearchTemplate>() { new SearchTemplate() { key = "parent_id", value = item.id, searchType = EnumBase.SearchType.Eq } }; var list_ntsub = b_nt.GetList(st, order); foreach (var sub in list_ntsub) { list.Add(sub); } } var total = list_nt_count; return(Json(new { total = total, rows = list }, JsonRequestBehavior.AllowGet)); }
public JsonResult AddNews(int txt_parent_id, string txt_is_lock, string txt_action_type, string txt_title, int?txt_sort_id, int?txt_click, DateTime?start_time, string txt_source, string txt_author, string txt_summary, string txtContent, string txt_seo_title, string txt_seo_keywords, string txt_seo_description) { Common.Json json = new Common.Json(); var fileName = ""; var name = ""; if (Request.Files.Count == 0) { //json.msg = "没有文件!"; //json.status = -1; //return Json(json); } else { HttpPostedFileBase file = Request.Files[0]; name = "news/" + DateTime.Now.ToString("yyyyMMddhhmmss") + Path.GetExtension(file.FileName); fileName = Path.Combine(Request.MapPath("/") + "../Images", name); try { file.SaveAs(fileName); } catch { //json.msg = "上传异常!"; //json.status = -1; //return Json(json); } } DAO.BLL.B_News b_new = new DAO.BLL.B_News(); DAO.BLL.B_News_type b_nt = new B_News_type(); DAO.BLL.B_Manager b_manager = new B_Manager(); Domain.News m_new = new Domain.News(); m_new.news_type = b_nt.Get(txt_parent_id); m_new.is_lock = txt_is_lock; if (!string.IsNullOrEmpty(txt_action_type)) { if (txt_action_type.Contains(EnumBase.RecommendType.置顶.Description())) { m_new.is_top = 1; } if (txt_action_type.Contains(EnumBase.RecommendType.热门.Description())) { m_new.is_hot = 1; } if (txt_action_type.Contains(EnumBase.RecommendType.推荐.Description())) { m_new.is_red = 1; } if (txt_action_type.Contains(EnumBase.RecommendType.允许评论.Description())) { m_new.is_msg = 1; } } m_new.title = txt_title; m_new.img_url = name; m_new.sort_id = txt_sort_id; m_new.source = txt_source; m_new.author = txt_author; m_new.summary = txt_summary; m_new.content = txtContent; m_new.start_time = start_time; m_new.add_time = DateTime.Now; m_new.click = txt_click; m_new.manager = b_manager.Get(Convert.ToInt32(base.User.Identity.Name)); m_new.seo_title = txt_seo_title; m_new.seo_keywords = txt_seo_keywords; m_new.seo_description = txt_seo_description; var res = b_new.Save(m_new); if (res > 0) { json.msg = "添加成功!"; } else { json.msg = "添加失败!"; json.status = -1; } return(Json(json)); }