public ActionResult Detail(int?id) { try { var entity = new Domain.SYS_CHANNEL() { IsDisplay = true }; var query = ChannelManage.LoadListAll(null); if (id != null && id > 0) { entity = ChannelManage.Get(p => p.ID == id); query = query.Where(p => p.ID != id).ToList(); } var parentId = Request.QueryString["parentId"]; var typeId = Request.QueryString["typeId"]; if (!string.IsNullOrEmpty(parentId)) { int parent = int.Parse(parentId); entity.ParentID = parent; } if (!string.IsNullOrEmpty(typeId)) { int type = int.Parse(typeId); entity.TypeId = type; } ViewData["Channels"] = Common.JsonConverter.JsonClass(ChannelManage.RecursiveModule(query).Select(p => new { p.ID, Title = GetTitle2(p.Tilte, p.Levels) })); return(View(entity)); } catch (Exception e) { WriteLog(Common.Enums.enumOperator.Select, "频道管理加载详情", e); throw e.InnerException; } }
public ActionResult Save(Domain.SYS_CHANNEL entity) { bool IsEdit = false; var json = new JsonHelper() { Msg = "保存成功", Status = "n" }; try { if (entity == null) { json.Msg = "频道不存在!"; } else { if (entity.ID > 0) { IsEdit = true; entity.UpdateDate = DateTime.Now; entity.UpdateUser = CurrentUser.Name; } else { entity.CreateDate = DateTime.Now; entity.CreateUser = CurrentUser.Name; entity.UpdateDate = DateTime.Now; entity.UpdateUser = CurrentUser.Name; } if (entity.ParentID > 0) { entity.Levels = ChannelManage.Get(p => p.ID == entity.ParentID).Levels + 1; } else { entity.Levels = 0; } if (ChannelManage.IsExist(p => p.ParentID == entity.ParentID && p.ID != entity.ID && p.Tilte == entity.Tilte)) { json.Msg = "子频道名称不能重复!"; } else { if (ChannelManage.SaveOrUpdate(entity, IsEdit)) { if (IsEdit) { ChannelManage.MoreModifyModule(entity.ID, entity.Levels); } json.Status = "y"; } else { json.Msg = "保存失败!"; } } } } catch (Exception e) { json.Msg = "保存频道发生内部错误!"; WriteLog(Common.Enums.enumOperator.None, "保存频道:", e); } return(Json(json)); }