Exemplo n.º 1
0
        /// <summary>
        /// 添加用户角色
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="roleIds">用,分隔的角色ID</param>
        /// <returns></returns>
        public int Add(int userId, string[] roleIds, Eastcom.Model.v_Sys_User_Info uModel)
        {
            //先删除该用户的所有角色
            this.DelWhere(string.Format("FK_UserID={0}", userId));

            int result = 0;

            int[] ids = CommonClass.StringHander.Common.GetIntArrayByStringArray(roleIds);
            if (ids.Length > 0)
            {
                Eastcom.Model.Sys_Power_UserRole model = null;

                for (int i = 0; i < ids.Length; i++)
                {
                    if (ids[i] == 0)
                    {
                        continue;
                    }
                    model             = new Model.Sys_Power_UserRole();
                    model.CreateTime  = DateTime.Now;
                    model.FK_CreateID = uModel.UserID;
                    model.FK_RoleId   = ids[i];
                    model.FK_UserId   = userId;
                    if (this.Add(model) > 0)
                    {
                        result++;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Eastcom.Model.Sys_Power_UserRole model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Eastcom.Model.Sys_Power_UserRole model)
 {
     return(dal.Add(model));
 }