/// <summary> /// 根据Id获取节点数据 /// </summary> /// <param name="id"></param> /// <returns></returns> public MsgResult GetMenuTreeNodeById(int id = 0) { MsgResult result = new MsgResult(); SysMenus menu = new SysMenus(); try { if (id <= 0) { result.IsSuccess = false; result.Message = "传递参数错误"; } else { var node = SysMenuDal.GetModels(x => x.IsDeleted == false & x.Id == id).FirstOrDefault(); var parentNode = SysMenuDal.GetModels(x => x.IsDeleted == false & x.Id == node.ParentId).FirstOrDefault(); menu = Mapper.Map <SysMenus>(node); menu.ParentName = parentNode.MenuName; result.IsSuccess = true; result.Data = JsonConvert.SerializeObject(menu); } } catch (Exception ex) { result.IsSuccess = false; result.Message = ex.Message; logger.Error(ex.Message); } return(result); }
/// <summary> /// 保存菜单 /// </summary> /// <param name="model"></param> /// <returns></returns> public OperateResult SaveMenu(SysMenus model) { var result = OperateResult.Fail("数据保存失败!"); try {//todo: Set Depth if (model.Id > 0) { var obj = _sysMenusRepository.Get(model.Id); model.ToCopyProperty(obj); _sysMenusRepository.SaveChanges(); result = OperateResult.Success("数据保存成功"); } else { model.MenuId = _sysMenusRepository.GetMaxMenuId(); model.SortOrder = _sysMenusRepository.GetMenuMaxIndex(model.PMenuId) + 1; _sysMenusRepository.CreateWithSaveChanges(model); result = OperateResult.Success("数据保存成功"); } } catch (Exception ex) { result = OperateResult.Fail("数据保存失败!" + ex.Message); } return(result); }
public async Task <IHttpActionResult> PutSysMenu(int id, SysMenus sysMenu) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } if (id != sysMenu.Id) { return(this.BadRequest()); } this.db.Entry(sysMenu).State = EntityState.Modified; try { await this.db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!this.SysMenuExists(id)) { return(this.NotFound()); } else { throw; } } return(this.StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// 跟新菜单节点 /// </summary> /// <param name="node"></param> /// <returns></returns> public MsgResult UpdateMenuNode(SysMenus node) { MsgResult result = new MsgResult(); T_SysMenus menuEntity = new T_SysMenus(); try { menuEntity = Mapper.Map <T_SysMenus>(node); SysMenuDal.UpdateEntityFields(menuEntity, new List <string> { "MenuName", "MenuUrl", "SortNum" }); SysMenuDal.SaveChanges(); CacheHelper.RemoveCache("menuList"); result.IsSuccess = true; result.Message = "跟新数据成功"; } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var ve in ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors)) { sb.AppendLine(ve.PropertyName + ":" + ve.ErrorMessage); } result.IsSuccess = false; result.Message = "跟新失败:" + sb.ToString(); } catch (Exception ex) { result.IsSuccess = false; result.Message = "跟新失败:" + ex.Message; } return(result); }
/// <summary> /// 标记删除节点 /// </summary> /// <param name="node"></param> /// <returns></returns> public MsgResult MarkDeleteNode(SysMenus node) { MsgResult result = new MsgResult(); T_SysMenus menuEntity = new T_SysMenus(); try { menuEntity = Mapper.Map <T_SysMenus>(node); menuEntity.IsDeleted = true; SysMenuDal.MarkDelete(menuEntity); SysMenuDal.SaveChanges(); CacheHelper.RemoveCache("menuList"); result.IsSuccess = true; result.Message = "删除数据成功"; } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var ve in ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors)) { sb.AppendLine(ve.PropertyName + ":" + ve.ErrorMessage); } result.IsSuccess = false; result.Message = "删除数据失败:" + sb.ToString(); } catch (Exception ex) { result.IsSuccess = false; result.Message = "删除数据失败:" + ex.Message; } return(result); }
/// <summary> /// 根据菜单节点获取子菜单数据 /// </summary> /// <param name="id"></param> /// <returns></returns> public MsgResult GetMenuTreeChildNodeListById(int id = 0) { MsgResult result = new MsgResult(); List <SysMenus> list = new List <SysMenus>(); SysMenus menu = new SysMenus(); try { if (id <= 0) { result.IsSuccess = false; result.Message = "传递参数错误"; } else { var parentNode = SysMenuDal.GetModels(x => x.IsDeleted == false & x.Id == id).FirstOrDefault(); var model = SysMenuDal.GetModels(x => x.IsDeleted == false && x.ParentId == id).ToList(); //注意mapper 需要在查询出结果之后再使用,不能加入EF的表达式树中进行计算 list = model.Select(x => Mapper.Map <SysMenus>(x)).ToList(); list.ForEach(x => x.ParentName = parentNode.MenuName); result.IsSuccess = true; result.Data = JsonConvert.SerializeObject(list); } } catch (Exception ex) { result.IsSuccess = false; result.Message = ex.Message; logger.Error(ex.Message); } return(result); }
/// <summary> /// 保存菜单 /// </summary> /// <param name="model"></param> /// <returns></returns> public OpResult SaveMenu(SysMenus model) { var result = OpResult.Fail("数据保存失败!"); try {//todo: Set Depth model.CompanyId = Sys.SysCommonRules.CompanyId; if (_dal.ExistsById(model.Id)) { var re = _dal.Update(model); if (re) { result = OpResult.Success("数据保存成功"); } } else { var maxObjId = _dal.MaxVal("MenuId", SysCommonRules.CompanyId); model.MenuId = maxObjId + 1; model.SortOrder = _dal.GetMenuMaxIndex(model.PMenuId) + 1; var re = _dal.Insert(model); if (re > 0) { result = OpResult.Success("数据保存成功"); } } } catch (Exception ex) { result = OpResult.Fail("数据保存失败!" + ex.Message); new LogEngine().WriteError(ex); } return(result); }
/// <summary> /// 移动菜单,更改菜单排序 /// </summary> /// <param name="mode">1:上移,2:下移</param> /// <param name="menuId">菜单Id</param> /// <returns></returns> public OpResult MoveMenuItem(int mode, int menuId) { var result = OpResult.Fail("菜单项排序变更失败"); try { var childrens = _dal.FindParentChilds(menuId); var currentMenu = childrens.FirstOrDefault(o => o.MenuId == menuId); if (currentMenu != null) { switch (mode) { case 1: var minSortOrder = childrens.Min(o => o.SortOrder); if (currentMenu.SortOrder > minSortOrder) { SysMenus previousMenu = null; int i = 1; while (previousMenu == null && (currentMenu.SortOrder - i) >= minSortOrder) { previousMenu = childrens.FirstOrDefault(o => o.SortOrder == (currentMenu.SortOrder - i)); i++; } var sortOrder = currentMenu.SortOrder; currentMenu.SortOrder = previousMenu.SortOrder; previousMenu.SortOrder = sortOrder; _dal.UpdateMenuOrderIndex(previousMenu); _dal.UpdateMenuOrderIndex(currentMenu); } break; case 2: var maxSortOrder = childrens.Max(o => o.SortOrder); if (currentMenu.SortOrder < maxSortOrder) { SysMenus previousMenu = null; int i = 1; while (previousMenu == null && (currentMenu.SortOrder + i) <= maxSortOrder) { previousMenu = childrens.FirstOrDefault(o => o.SortOrder == (currentMenu.SortOrder + i)); i++; } var sortOrder = currentMenu.SortOrder; currentMenu.SortOrder = previousMenu.SortOrder; previousMenu.SortOrder = sortOrder; _dal.UpdateMenuOrderIndex(previousMenu); _dal.UpdateMenuOrderIndex(currentMenu); } break; } } result = OpResult.Success("数据保存成功"); } catch (Exception e) { result = OpResult.Fail("菜单项排序变更失败" + e.Message); } return(result); }
/// <summary> /// 增加菜单节点 /// </summary> /// <param name="node"></param> /// <returns></returns> public MsgResult AddMenuNode(SysMenus node) { MsgResult result = new MsgResult(); T_SysMenus entity = new T_SysMenus(); try { entity = Mapper.Map <T_SysMenus>(node); entity.Guid = Guid.NewGuid().ToString("N"); entity.CreateUser = 1; entity.CreateTime = DateTime.Now; SysMenuDal.Add(entity); SysMenuDal.SaveChanges(); CacheHelper.RemoveCache("menuList"); result.IsSuccess = true; result.Message = "增加成功"; } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var ve in ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors)) { sb.AppendLine(ve.PropertyName + ":" + ve.ErrorMessage); } result.IsSuccess = false; result.Message = "增加失败:" + sb.ToString(); } catch (Exception ex) { result.IsSuccess = false; result.Message = "增加失败:" + ex.Message; } return(result); }
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary> //[EditorBrowsable(EditorBrowsableState.Never)] //protected override void InitData() //{ // base.InitData(); // // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用 // // Meta.Count是快速取得表记录数 // if (Meta.Count > 0) return; // // 需要注意的是,如果该方法调用了其它实体类的首次数据库操作,目标实体类的数据初始化将会在同一个线程完成 // if (XTrace.Debug) XTrace.WriteLine("开始初始化{0}[{1}]数据……", typeof(SysFunction).Name, Meta.Table.DataTable.DisplayName); // var entity = new SysFunction(); // entity.Serialnum = "abc"; // entity.CreateTime = DateTime.Now; // entity.CreateSysUserSerialnum = "abc"; // entity.UpdateTime = DateTime.Now; // entity.UpdateSysUserSerialnum = "abc"; // entity.Name = "abc"; // entity.ParentSerialnum = "abc"; // entity.Controller = "abc"; // entity.Action = "abc"; // entity.Description = "abc"; // entity.Status = 0; // entity.Sort = 0; // entity.Remark = "abc"; // entity.Insert(); // if (XTrace.Debug) XTrace.WriteLine("完成初始化{0}[{1}]数据!", typeof(SysFunction).Name, Meta.Table.DataTable.DisplayName); //} /// <summary>已重载。删除关联数据</summary> /// <returns></returns> protected override int OnDelete() { if (SysMenus != null) { SysMenus.Delete(); } return(base.OnDelete()); }
public SysMenusExt(SysMenus model) { Id = model.Id; PId = model.PId; Title = model.Title; Status = model.Status; LimitsCode = model.LimitsCode; SortOrder = model.SortOrder; URL = model.URL; }
public async Task <IHttpActionResult> GetSysMenu(int id) { SysMenus sysMenu = await this.db.SysMenus.FindAsync(id); if (sysMenu == null) { return(this.NotFound()); } return(this.Ok(sysMenu)); }
public async Task <IHttpActionResult> PostSysMenu(SysMenus sysMenu) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } this.db.SysMenus.Add(sysMenu); await this.db.SaveChangesAsync(); return(this.CreatedAtRoute("DefaultApi", new { id = sysMenu.Id }, sysMenu)); }
public async Task <IHttpActionResult> DeleteSysMenu(int id) { SysMenus sysMenu = await this.db.SysMenus.FindAsync(id); if (sysMenu == null) { return(this.NotFound()); } this.db.SysMenus.Remove(sysMenu); await this.db.SaveChangesAsync(); return(this.Ok(sysMenu)); }
public AjaxResponse SaveMenusModel(MenusInput model) { long resId; var isRepeat = IsPermissionRepeat(model.PermissionName, model.ID); if (isRepeat) { throw new UserFriendlyException("菜单授权名称重复", "您设置的授权名称" + model.PermissionName + "重复!"); } if (model.ID == null) { SysMenus modelInput = model.MapTo <SysMenus>(); resId = _sysMenusRepository.InsertAndGetId(modelInput); } else { MenusUpdata modelInput = model.MapTo <MenusUpdata>(); long id = Convert.ToInt64(model.ID); //获取需要更新的数据 SysMenus data = _sysMenusRepository.Get(id); //映射需要修改的数据对象 SysMenus m = ObjectMapper.Map(modelInput, data); //修改动作明细数据 List <SysMenuAction> menuActionList = model.SysMenuActions.MapTo <List <SysMenuAction> >(); if (menuActionList != null && menuActionList.Any()) { _sysMenuActionRepository.UpdataMenusAction(menuActionList, id); } else { //如果保存时候未发现有设置的动作列表就清除掉原有的动作 _sysMenuActionRepository.DelMenusAction(id); } //修改菜单主数据 var resModel = _sysMenusRepository.Update(m); resId = resModel.Id; } //清除模块缓存 _cacheManagerExtens.RemoveMenuActionPermissionCache(); //重置初始菜单以及授权 _navigationMenusExt.UpNavigationMenusProvider(model.MapTo <SysMenus>()); return(new AjaxResponse { Success = true, Result = new { id = resId } }); }
/// <summary> /// 增加 /// </summary> /// <param name="SysMenus">SysMenus实体对象</param> /// <returns>int值,返回自增ID</returns> public int addReturnId(SysMenus model) { SqlParameter[] param = new SqlParameter[] { new SqlParameter ("@Menu_Name",model.Menu_Name), new SqlParameter ("@Menu_Title",model.Menu_Title), new SqlParameter ("@Menu_Img",model.Menu_Img), new SqlParameter ("@Menu_Type",model.Menu_Type), new SqlParameter ("@Menu_Order",model.Menu_Order), new SqlParameter ("@Menu_Url",model.Menu_Url), new SqlParameter ("@Menu_PanelID",model.Menu_PanelID), new SqlParameter ("@Menu_Status",model.Menu_Status) }; return Convert.ToInt32(Helper.ExecuteScalar ("SysMenus_AddReturnId",param)); }
/// <summary> /// 增加 /// </summary> /// <param name="SysMenus">SysMenus实体对象</param> /// <returns>bool值,判断是否操作成功</returns> public bool add(SysMenus model) { SqlParameter[] param = new SqlParameter[] { new SqlParameter ("@Menu_Name",model.Menu_Name), new SqlParameter ("@Menu_Title",model.Menu_Title), new SqlParameter ("@Menu_Img",model.Menu_Img), new SqlParameter ("@Menu_Type",model.Menu_Type), new SqlParameter ("@Menu_Order",model.Menu_Order), new SqlParameter ("@Menu_Url",model.Menu_Url), new SqlParameter ("@Menu_PanelID",model.Menu_PanelID), new SqlParameter ("@Menu_Status",model.Menu_Status) }; return Helper.ExecuteNonQuery("SysMenus_Add",param); }
private EasyuiTree GetMenusChildsEasyuiTreeData(SysMenus menu, List <SysMenus> source) { var model = new EasyuiTree { id = menu.MenuId.ToString(), text = menu.Title }; var childs = source.Where(s => s.PMenuId == menu.MenuId && s.Status == true); if (childs.Count() > 0) { model.children = new List <EasyuiTree>(); childs.Each(t => { model.children.Add(GetMenusChildsEasyuiTreeData(t, source)); }); } return(model); }
public AjaxResponse SaveMenusModel(MenusInput model) { long resId; #region 验证 MenuData menuData = ObjectMapper.Map <MenuData>(model); var isRepeat = IsPermissionRepeat(menuData); if (isRepeat) { throw new UserFriendlyException("菜单授权名称重复", "您设置的授权名称" + model.PermissionName + "重复!"); } #endregion if (model.Id == null) { #region 新增 SysMenus modelInput = ObjectMapper.Map <SysMenus>(model); resId = _sysMenusRepository.InsertAndGetId(modelInput); #endregion } else { #region 编辑 long id = Convert.ToInt64(model.Id); //获取需要更新的数据 SysMenus data = _sysMenusRepository.Get(id); //映射需要修改的数据对象 SysMenus sysMenus = ObjectMapper.Map(model, data); //清空映射对象中的子表集合(子表集合单独处理,不采用EF的循环调整对象的方式) sysMenus.SysMenuActions.Clear(); //修改动作明细数据 List <SysMenuAction> menuActionList = ObjectMapper.Map <List <SysMenuAction> >(model.SysMenuActions); _sysMenuActionRepository.UpdataMenusAction(menuActionList, id); //修改菜单主数据 var resModel = _sysMenusRepository.Update(sysMenus); resId = resModel.Id; #endregion } //清除模块缓存 _cacheManagerExtens.RemoveMenuActionPermissionCache(); //重置初始菜单以及授权 _navigationMenusExt.UpNavigationMenusProvider(ObjectMapper.Map <SysMenus>(model)); return(new AjaxResponse { Success = true, Result = new { id = resId } }); }
public bool InsertMenu(MenuModel model) { try { var mn = new SysMenus { Id = model.Id, SortOrder = model.Sequence ?? 0, Name = model.Name, URL = model.URL, IconCss = model.Icon, ParentId = model.ParentId }; _db.SysMenus.Add(mn); _db.SaveChanges(); return(true); } catch (Exception ex) { LogHelper.Error("MenuRepository insert: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(false); } }
/// <summary> /// 查看全部 /// </summary> /// <returns>list集合</returns> public List<SysMenus> selectAll() { List<SysMenus> list = new List<SysMenus>(); SysMenus model = null; using (SqlDataReader dr = Helper.ExecuteReader("SysMenus_SelectAll", null)) { while (dr.Read()) { model = new SysMenus(); model.Menu_Id = dr["Menu_Id"].ToString(); if (DBNull.Value!=dr["Menu_Name"]) model.Menu_Name = dr["Menu_Name"].ToString(); if (DBNull.Value!=dr["Menu_Title"]) model.Menu_Title = dr["Menu_Title"].ToString(); if (DBNull.Value!=dr["Menu_Img"]) model.Menu_Img = dr["Menu_Img"].ToString(); if (DBNull.Value!=dr["Menu_Type"]) model.Menu_Type = dr["Menu_Type"].ToString(); if (DBNull.Value!=dr["Menu_Order"]) model.Menu_Order = dr["Menu_Order"].ToString(); if (DBNull.Value!=dr["Menu_Url"]) model.Menu_Url = dr["Menu_Url"].ToString(); if (DBNull.Value!=dr["Menu_PanelID"]) model.Menu_PanelID = dr["Menu_PanelID"].ToString(); if (DBNull.Value!=dr["Menu_Status"]) model.Menu_Status = dr["Menu_Status"].ToString(); list.Add(model); } } return list; }
/// <summary> /// 通过条件查询 /// </summary> /// <param name="WhereString">查询条件</param> /// <returns>SysMenus实体类对象</returns> public List<SysMenus> selectByWhere(string WhereString) { SqlParameter[] param = new SqlParameter[] { new SqlParameter ("@where",WhereString) }; List<SysMenus> list = new List<SysMenus>(); SysMenus model = null; using (SqlDataReader dr = Helper.ExecuteReader("SysMenus_SelectByWhere", param)) { while (dr.Read()) { model = new SysMenus(); model.Menu_Id = dr["Menu_Id"].ToString(); if (DBNull.Value!=dr["Menu_Name"]) model.Menu_Name = dr["Menu_Name"].ToString(); if (DBNull.Value!=dr["Menu_Title"]) model.Menu_Title = dr["Menu_Title"].ToString(); if (DBNull.Value!=dr["Menu_Img"]) model.Menu_Img = dr["Menu_Img"].ToString(); if (DBNull.Value!=dr["Menu_Type"]) model.Menu_Type = dr["Menu_Type"].ToString(); if (DBNull.Value!=dr["Menu_Order"]) model.Menu_Order = dr["Menu_Order"].ToString(); if (DBNull.Value!=dr["Menu_Url"]) model.Menu_Url = dr["Menu_Url"].ToString(); if (DBNull.Value!=dr["Menu_PanelID"]) model.Menu_PanelID = dr["Menu_PanelID"].ToString(); if (DBNull.Value!=dr["Menu_Status"]) model.Menu_Status = dr["Menu_Status"].ToString(); list.Add(model); } } return list; }
/// <summary> /// 通过Id查询 /// </summary> /// <param name="Id">主键Id</param> /// <returns>SysMenus实体类对象</returns> public SysMenus selectById(int Id) { SqlParameter[] param = new SqlParameter[] { new SqlParameter ("@Menu_Id",Id) }; SysMenus model = new SysMenus(); using (SqlDataReader dr = Helper.ExecuteReader("SysMenus_SelectById", param)) { if (dr.Read()) { model.Menu_Id = dr["Menu_Id"].ToString(); if (DBNull.Value!=dr["Menu_Name"]) model.Menu_Name = dr["Menu_Name"].ToString(); if (DBNull.Value!=dr["Menu_Title"]) model.Menu_Title = dr["Menu_Title"].ToString(); if (DBNull.Value!=dr["Menu_Img"]) model.Menu_Img = dr["Menu_Img"].ToString(); if (DBNull.Value!=dr["Menu_Type"]) model.Menu_Type = dr["Menu_Type"].ToString(); if (DBNull.Value!=dr["Menu_Order"]) model.Menu_Order = dr["Menu_Order"].ToString(); if (DBNull.Value!=dr["Menu_Url"]) model.Menu_Url = dr["Menu_Url"].ToString(); if (DBNull.Value!=dr["Menu_PanelID"]) model.Menu_PanelID = dr["Menu_PanelID"].ToString(); if (DBNull.Value!=dr["Menu_Status"]) model.Menu_Status = dr["Menu_Status"].ToString(); } } return model; }
/// <summary> /// /// </summary> /// <param name="context"></param> private void SetChildrenMenusNavigation(MenuItemDefinition subMenuItemDefinition, SysMenus model) { foreach (var item in model.ChildrenMenus) { MenuItemDefinition menuItemDefinition = new MenuItemDefinition( name: item.MenuName, displayName: new FixedLocalizableString(item.MenuDisplayName), icon: item.Icon, url: item.Url, requiresAuthentication: item.IsRequiresAuth, requiredPermissionName: item.PermissionName, customData: null, order: Convert.ToInt32(item.OrderBy) ); subMenuItemDefinition.AddItem(menuItemDefinition); SetChildrenMenusNavigation(menuItemDefinition, item); } }
public ActionResult MarkDeleteNode(SysMenus node) { var result = SysMenuService.MarkDeleteNode(node); return(Json(result)); }
public ActionResult UpdateMenuNode(SysMenus node) { var result = SysMenuService.UpdateMenuNode(node); return(Json(result)); }
public IActionResult Form(SysMenus sysMenus) { ResponseResult responseResult = new ResponseResult(success: false, message: "保存失败!"); try { if (string.IsNullOrEmpty(sysMenus.ObjectID)) { #region 层级获取判断 int hierarchy = 1; if (!sysMenus.ParentID.Equals("0")) { //搜索父节点的层级 int on = (int)Status.On; var parentHierarchy = _sysMenusService.GetList(m => m.ObjectID.Equals(sysMenus.ParentID) && m.Status.Equals(on)).Select(m => m.Hierarchy).FirstOrDefault(); hierarchy = (int)(parentHierarchy + 1); } //判断当前层级是不是超过了最大层级限制 if (hierarchy > GlobalSwitch.MenuMaxHierarchy) { throw new Exception($"当前菜单已经超过系统设定菜单最大层级【{GlobalSwitch.MenuMaxHierarchy}】层,如需要继续添加请修改系统配置!"); } #endregion sysMenus.ObjectID = Guid.NewGuid().ToString(); sysMenus.CreatedBy = CurrentUserManage.UserInfo.URealName; sysMenus.CreatedTime = DateTime.Now; sysMenus.IsLast = sysMenus.IsLast == 0 ? 0 : 1; sysMenus.IsMenuShow = sysMenus.IsMenuShow == 0 ? 0 : 1; sysMenus.Status = sysMenus.Status == 0 ? 0 : 1; sysMenus.Hierarchy = hierarchy; //末级菜单 默认创建 查询和管理权限项 if (sysMenus.IsLast == 0) { sysMenus.SysFunction = BuildFunctions(sysMenus.ObjectID, sysMenus.MArea, sysMenus.MController); } _sysMenusService.Create(sysMenus); _unitOfWork.SaveChanges(); responseResult.Success = true; responseResult.Message = "保存成功!"; } else { var model = _sysMenusService.GetList(m => m.ObjectID.Equals(sysMenus.ObjectID)) .FirstOrDefault(); if (model != null) { model.MName = sysMenus.MName; model.MArea = sysMenus.MArea; model.MController = sysMenus.MController; model.MIcon = sysMenus.MIcon; model.IsLast = sysMenus.IsLast == 0 ? 0 : 1; model.IsMenuShow = sysMenus.IsMenuShow == 0 ? 0 : 1; model.Remark = sysMenus.Remark; model.ParentID = sysMenus.ParentID; model.Sort = sysMenus.Sort; //后台设置项 model.Status = sysMenus.Status == 0 ? 0 : 1; model.ModifiedTime = DateTime.Now; model.ModifiedBy = CurrentUserManage.UserInfo.URealName; _sysMenusService.Edit(model); if (_unitOfWork.SaveChanges() == 1) { responseResult.Success = true; responseResult.Message = "保存成功!"; } } else { responseResult.Message = "要修改的数据不存在!"; } } } catch (Exception ex) { responseResult.Message = ex.Message; } return(Json(responseResult)); }
public ActionResult MenusSave(SysMenus model) { var result = _menuBLL.SaveMenu(model); return(Content(result.ToJson())); }