コード例 #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;
        }
コード例 #2
0
        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);


        }
コード例 #3
0
        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;
         
        }