Exemplo n.º 1
0
        /// <summary>
        /// 新增userPrivilege
        /// </summary>
        /// <param name="model"></param>
        public void AddUserPrivilege(UserUpdateModule model)
        {
            List <string>         sql   = new List <string>();
            List <SqlParameter[]> param = new List <SqlParameter[]>();

            for (int i = 0; i < model.UserPrivilegeList.Count; i++)
            {
                StringBuilder str_insert = new StringBuilder();
                str_insert.AppendLine("INSERT INTO User_Menu");
                str_insert.AppendLine("(UserID, MenuID, IsSelected)");
                str_insert.AppendLine(" VALUES ");
                str_insert.AppendLine(" (@UserID, @MenuID, @IsSelected)");

                SqlParameter[] paras2 = new SqlParameter[3];
                paras2[0] = new SqlParameter("@UserID", model.UserNameSearch.UserID);
                paras2[1] = new SqlParameter("@MenuID", model.UserPrivilegeList[i].MenuID);
                paras2[2] = new SqlParameter("@IsSelected", model.UserPrivilegeList[i].IsSelected);


                sql.Add(str_insert.ToString());
                param.Add(paras2);
            }

            SqlAccess mySqlAccess_insert = new SqlAccess();

            mySqlAccess_insert.ExecuteNonQuerys(sql, param);
        }
Exemplo n.º 2
0
        public async Task UpdateAsync_Test()
        {
            // Arrange
            var user = new UserUpdateModule
            {
                Id            = 1021,
                Name          = "Admin 21",
                ChangedFields = new[] { "name" }
            };

            // Act
            var(result, data) = await repo.QuickUpdateAsync(user, new(new[] { "Name" }));

            // Assert
            Assert.IsTrue(result.Ok);
            Assert.IsNotNull(data);
            Assert.AreEqual(1, data?.RowsAffected);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取User管理详细页面数据
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public UserUpdateModule GetUserByID(string userID)
        {
            StringBuilder str = new StringBuilder();

            str.AppendLine(" SELECT ");
            str.AppendLine(" UserID, Username, Password, IsDelete ");
            str.AppendLine(" FROM LoginUser with(Nolock)");
            str.AppendLine(" WHERE UserID = @UserID");

            SqlParameter[] paras = new SqlParameter[1];
            paras[0] = new SqlParameter("@UserID", userID);

            SqlAccess mySqlAccess = new SqlAccess();
            DataSet   ds          = mySqlAccess.ExecuteAdapter(str.ToString(), paras);

            UserUpdateModule user = new UserUpdateModule();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                user = DataMappingHelper <UserUpdateModule> .DataTableToEntity(ds.Tables[0]);
            }
            return(user);
        }