コード例 #1
0
ファイル: UserBLL.cs プロジェクト: MateralCMX/HuaLiangWindow
        /// <summary>
        /// 添加一个用户组
        /// </summary>
        /// <param name="userID">用户唯一标识</param>
        /// <param name="userGroupID">用户组唯一标识</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ApplicationException"></exception>
        public void AddUserGroup(Guid userID, Guid userGroupID)
        {
            T_User userM = _dal.GetDBModelInfoByID(userID);

            if (userM != null)
            {
                T_UserGroup userGroupM = _dal.GetUserGroupInfoByID(userGroupID);
                if (userGroupM != null)
                {
                    if (userM.T_UserGroup.Where(m => m.ID == userGroupID).FirstOrDefault() == null)
                    {
                        userM.T_UserGroup.Add(userGroupM);
                        _dal.SaveChange();
                    }
                    else
                    {
                        throw new ApplicationException("已拥有该用户组");
                    }
                }
                else
                {
                    throw new ArgumentException("用户组不存在");
                }
            }
            else
            {
                throw new ArgumentException("用户不存在");
            }
        }
コード例 #2
0
        public async Task AddUserToGroupAsync(long groupId, long userId)
        {
            T_UserGroup userGroup = new T_UserGroup
            {
                UserId     = userId,
                GroupId    = groupId,
                CreateDate = DateTime.Now
            };

            this.Db.Set <T_UserGroup>().Add(userGroup);
            await this.Db.SaveChangesAsync();
        }
コード例 #3
0
 /// <summary>
 ///  实现 编辑
 /// </summary>
 /// <param name="userGroup"></param>
 /// <param name="group_id"></param>
 /// <returns></returns>
 public bool EditGroup(T_UserGroup userGroup, int group_id)
 {
     if (null == userGroup)
     {
         return(false);
     }
     userGroup.group_id    = group_id;
     userGroup.update_date = DateTime.Now;
     userGroup.update_id   = OperateContext.Current.Usr.user_id;
     Modify(userGroup, "group_name", "group_cname", "update_id", "update_date", "group_note", "sm_code");
     return(true);
 }
コード例 #4
0
ファイル: PermissionsBLL.cs プロジェクト: MateralCMX/KotenBu
        /// <summary>
        /// 根据用户组获得拥有权限的
        /// </summary>
        /// <param name="userGroupID">用户组ID</param>
        /// <returns>拥有的权限ID</returns>
        /// <exception cref="ArgumentException"></exception>
        public Guid[] GetHasPermissionsIDsByUserGroupID(Guid userGroupID)
        {
            T_UserGroup userGroupM = _userGroupDAL.GetDBModelInfoByID(userGroupID);

            if (userGroupM != null)
            {
                Guid[] ids = (from m in userGroupM.T_Permissions
                              where !m.IfDelete && m.IfEnable
                              select m.ID).ToArray();
                return(ids);
            }
            else
            {
                throw new ArgumentException("该用户组不存在");
            }
        }
コード例 #5
0
        /// <summary>
        /// 实现 添加
        /// </summary>
        /// <param name="userGroup"></param>
        /// <returns></returns>
        public bool AddGroup(T_UserGroup userGroup)
        {
            if (null == userGroup)
            {
                return(false);
            }
            userGroup.creator_date = DateTime.Now;
            userGroup.creator_id   = OperateContext.Current.Usr.user_id;
            userGroup.group_order  = 1;
            int count = Add(userGroup);

            if (count > 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #6
0
 public ActionResult AddGroup(T_UserGroup userGroup)
 {
     if (!ModelState.IsValid)
     {
         return(operateContext.RedirectAjax(1, "数据验证失败~", "", ""));
     }
     try
     {
         bool Isback = base.operateContext.bllSession.T_UserGroup.AddGroup(userGroup);
         if (Isback)
         {
             return(operateContext.RedirectAjax(0, "添加成功~", "", ""));
         }
         return(operateContext.RedirectAjax(1, "添加失败~", "", ""));
     }
     catch (Exception ex)
     {
         return(operateContext.RedirectAjax(1, ex.Message, "", ""));
     }
 }
コード例 #7
0
        public ActionResult EditGroup(T_UserGroup userGroup)
        {
            if (!ModelState.IsValid)
            {
                return(operateContext.RedirectAjax(1, "数据验证失败~", "", ""));
            }
            int group_id = HCQ2_Common.Helper.ToInt(Request["group_id"]);

            if (group_id <= 0)
            {
                return(operateContext.RedirectAjax(1, "权限主键值为空~", "", ""));
            }
            bool IsBack = base.operateContext.bllSession.T_UserGroup.EditGroup(userGroup, group_id);

            //清理角色缓存
            SessionHelper.RemoveSession(CacheConstant.loginUserCacheRoles);
            if (IsBack)
            {
                return(operateContext.RedirectAjax(0, "编辑权限成功~", "", ""));
            }
            return(operateContext.RedirectAjax(1, "编辑权限失败~", "", ""));
        }