/// <summary> /// 删除菜单 /// </summary> /// <param name="MenuId"></param> /// <returns></returns> public HandleResult <bool> DelMenu(string MenuId) { bool bResult = false; //获取菜单 var menuModel = sysMenuDAL.GetModels(t => t.MenuId.Equals(MenuId)).First(); //获取菜单与权限关联表 var relatedModel = sysAmRelatedDAL.GetModels(t => t.MenuId.Equals(MenuId)).First(); var authorityModel = sysAuthorityBLL.GetModels(y => y.AuthorityId.Equals(relatedModel.AuthorityId)).First(); sysMenuDAL.Delete(menuModel); sysAmRelatedDAL.Delete(relatedModel); sysAmRelatedDAL.SaveChanges(); sysAuthorityBLL.Delete(authorityModel); return(new HandleResult <bool> { Msg = "删除成功", Result = bResult }); }
/// <summary> /// 删除菜单(逻辑删除) /// </summary> /// <param name="MenuId"></param> /// <returns></returns> public MessageModel DelMenu(string MenuId) { bool bResult = false; //获取菜单 var menuModel = sysMenuDAL.GetModels(t => t.MenuId.Equals(MenuId)).First(); //获取菜单与权限关联表 var relatedModel = sysAmRelatedDAL.GetModels(t => t.MenuId.Equals(MenuId)).First(); var authorityModel = sysAuthorityBLL.GetModels(y => y.AuthorityId.Equals(relatedModel.AuthorityId)).First(); using (var tran = new TransactionScope()) { int i = 0; menuModel.DeleteSign = (int)SysEnum.Enum_DeleteSign.Sign_Undeleted; menuModel.DeleteTime = DateTime.Now; sysMenuDAL.Update(menuModel); if (sysMenuDAL.SaveChanges()) { i++; } authorityModel.DeleteSign = (int)SysEnum.Enum_DeleteSign.Sign_Undeleted; authorityModel.DeleteTime = DateTime.Now; if (sysAuthorityBLL.Update(authorityModel)) { i++; } if (i == 2) { bResult = true; tran.Complete(); } else { bResult = false; tran.Dispose(); } } return(new MessageModel { Message = "删除失败", Result = bResult }); }