Exemplo n.º 1
0
        /// <summary>
        /// 实现对菜单项的删除
        /// </summary>
        /// <param name="permissionInfo">菜单项的实体类</param>
        /// <returns>返回执行成功的标志</returns>
        public ActionResult UpdatePermissionGroup(BasePermissionGroup permissionGroup)
        {
            var editPermissionGroupInfo = _permissionGroupService.LoadEntities(c => c.ID == permissionGroup.ID).FirstOrDefault();

            if (editPermissionGroupInfo == null)
            {
                return(Content("请您检查,错误信息"));
            }
            editPermissionGroupInfo.GroupName   = permissionGroup.GroupName;
            editPermissionGroupInfo.GroupType   = permissionGroup.GroupType;
            editPermissionGroupInfo.SortCode    = permissionGroup.SortCode;
            editPermissionGroupInfo.AllowDelete = permissionGroup.AllowDelete;
            editPermissionGroupInfo.AllowEdit   = permissionGroup.AllowEdit;
            editPermissionGroupInfo.IsVisible   = permissionGroup.IsVisible;
            editPermissionGroupInfo.Enabled     = permissionGroup.Enabled;
            editPermissionGroupInfo.Description = permissionGroup.Description;
            editPermissionGroupInfo.ModifiedOn  = DateTime.Parse(DateTime.Now.ToString());
            BaseUser user = Session["UserInfo"] as BaseUser;

            editPermissionGroupInfo.ModifiedUserID = user.Code;
            editPermissionGroupInfo.ModifiedBy     = user.UserName;
            if (_permissionGroupService.UpdateEntity() > 0)
            {
                return(Content("OK"));
            }
            return(Content("Error"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 实现对菜单组的增加功能
        /// </summary>
        /// <param name="permission">菜单组的实体类</param>
        /// <returns>返回是否执行成功的菜单的类型</returns>
        public ActionResult AddPermissionGroup(BasePermissionGroup permissionGroup)
        {
            permissionGroup.AllowEdit         = 1;
            permissionGroup.AllowDelete       = 1;
            permissionGroup.IsVisible         = 1;
            permissionGroup.DeletionStateCode = 0;
            permissionGroup.Enabled           = 1;
            permissionGroup.CreateOn          = DateTime.Parse(DateTime.Now.ToString());
            BaseUser user = Session["UserInfo"] as BaseUser;

            permissionGroup.CreateUserID = user.Code;
            permissionGroup.CreateBy     = user.UserName;
            //执行添加代码,返回OK
            _permissionGroupService.AddEntity(permissionGroup);
            return(Content("OK"));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 实现删除菜单组的数据
        /// </summary>
        /// <param name="permissionInfo">菜单组的实体类</param>
        /// <param name="ID">权限的ID</param>
        /// <param name="Not">表示进行了什么操作</param>
        /// <returns>返回对权限操作的标识</returns>
        public ActionResult DeletePermissionGroup(BasePermissionGroup permissionGroup, string ID, string Not)
        {
            //首先判断是否传递过来了ID,如果传递过来了继续往下走,否则提示错误
            if (string.IsNullOrEmpty(ID))
            {
                return(Content("请您选择需要删除/还原的信息"));
            }
            //List集合解析传递过来的ID
            var        idStrs = ID.Split(',');
            List <int> list   = new List <int>();

            foreach (var idStr in idStrs)
            {
                list.Add(int.Parse(idStr));
            }
            //循环伪删除菜单组的数据
            if (Not == "not")
            {
                foreach (var permissionGroupID in list)
                {
                    var deletePermissionGroupInfo = _permissionGroupService.LoadEntities(c => c.ID == permissionGroupID).FirstOrDefault();
                    deletePermissionGroupInfo.DeletionStateCode = 1;
                    _permissionGroupService.UpdateEntity(permissionGroup);
                }
                return(Content("OK"));
            }
            //循环还原菜单组的数据
            else if (Not == "back")
            {
                foreach (var permissionGroupID in list)
                {
                    var deletePermissionGroupInfo = _permissionGroupService.LoadEntities(c => c.ID == permissionGroupID).FirstOrDefault();
                    deletePermissionGroupInfo.DeletionStateCode = 0;
                    _permissionGroupService.UpdateEntity(permissionGroup);
                }
                return(Content("OK"));
            }
            //循环直接删除菜单组的数据
            else
            {
                if (_permissionGroupService.DeletePermissionEntity(list) > 0)
                {
                    return(Content("OK"));
                }
            }
            return(Content("Error"));
        }