public void AddUserTest()
        {
            var result = _userReposity.AddUser(new User()
            {
                Id = 3, UserName = "******", Password = "******", NickName = "feng", CreationTime = DateTime.Now, RoleId = 1
            });

            Assert.True(result);
        }
Beispiel #2
0
        public void AddUserTest()
        {
            var result = _userReposity.AddUser(new User()
            {
                Id = 2, UserName = "******", Password = "******", NickName = "oldliu", CreationTime = DateTime.Now, RoleId = 1
            });

            Assert.IsTrue(result);
        }
Beispiel #3
0
        public async Task <ActionResult> Register([FromBody] BKRegisterInfo info)
        {
            int count = await _userReposity.CheckUserByAccountAndNickNameAsync(info.Account, info.NickName);

            if (count > 0)
            {
                // 先这样写
                return(Ok(CommonResult.Fail("account or nickName have been used")));
            }
            string salt = "baike";
            BkUser user = new BkUser {
                Account = info.Account, Password = MD5Util.GenerateMD5(info.Password, salt), Salt = salt
            };
            BkUserInfo userInfo = new BkUserInfo {
                NickName = info.NickName, State = 1, Icon = "user_default.jpg", BackgroundIcon = "back_default.jpg"
            };

            user.BkUserInfo = userInfo;
            _userReposity.AddUser(user);
            await _userReposity.SaveAsync();

            return(Ok(CommonResult.Success("register success")));
        }