//菜单新增 public ActionResult menuAdd(Function fun) { Random random = new Random(); int n = random.Next(10000, 100000); fun.NodeId = n; fun.ParentNodeId = n; fun.CreateTime = DateTime.Now; fun.IsDelete = 0; return(Json(FunctionManager.Add(fun), JsonRequestBehavior.AllowGet)); }
public ActionResult Insert(string DisplayName, int ParentNodeId, string NodeURL) { Function function = new Function(); //获取编号 if (ParentNodeId == 0) { int NodeId = functionManager.GetByWhere(item => item.IsDelete == 0 && item.ParentNodeId == 0).OrderByDescending(item => item.NodeId).Take(1).Select(item => item.NodeId).FirstOrDefault(); function.NodeId = NodeId + 10000; function.DisplayName = DisplayName; function.ParentNodeId = 0; function.CreateTime = DateTime.Now; function.CreateUser = "******"; function.IsDelete = 0; function.NodeURL = NodeURL; } else { int NodeId = functionManager.GetByWhere(item => item.IsDelete == 0 && item.ParentNodeId == ParentNodeId).OrderByDescending(item => item.NodeId).Take(1).Select(item => item.NodeId).FirstOrDefault(); function.NodeId = NodeId + 1000; function.DisplayName = DisplayName; function.ParentNodeId = ParentNodeId; function.CreateTime = DateTime.Now; function.CreateUser = "******"; function.IsDelete = 0; function.NodeURL = NodeURL; } bool val = functionManager.Add(function); if (val) { return(Json("新增成功", JsonRequestBehavior.AllowGet)); } else { return(Json("新增失败", JsonRequestBehavior.AllowGet)); } }