示例#1
0
        public async Task<IdentityResult> RegisterUser(UserModel userModel)
        {
            var user = new ApplicationUser
            {
                UserName = userModel.Name,
                Email = userModel.Email
            };

            var result = await userManager.CreateAsync(user, userModel.Password);
       
            return result;
        }
        public void should_succeed_if_registered()
        {


            AuthService auth = new AuthService();
            var acontroller = new AccountController(auth);
            acontroller.Request = new HttpRequestMessage();
            acontroller.Configuration = new HttpConfiguration();
            var p = new UserModel
           {
               Name = "*****@*****.**",
               Password = "******",
               ConfirmPassword = "******"

           };
            var res = acontroller.Register(p);


        }
        public async Task<IHttpActionResult> Register(UserModel userModel)
        {
            IHttpActionResult resultout;
            if (!ModelState.IsValid)
            {
                resultout = BadRequest(ModelState);
                return resultout;
            }

            var result = await authRepository.RegisterUser(userModel);

            var errorResult = GetErrorResult(result);

            if (errorResult != null)
            {
                resultout= errorResult;
                return resultout;
            }

           resultout= Ok();
           return resultout;
         
        }