コード例 #1
0
        public async Task<IdentityResult> RegisterUser(UserModel userModel)
        {
            IdentityUser user = new IdentityUser
            {
                UserName = userModel.UserName
            };

            var result = await _userManager.CreateAsync(user, userModel.Password);

            return result; 
        }
コード例 #2
0
        public async Task<System.Web.Http.IHttpActionResult> Register(UserModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return new BadRequest(ModelState);
            }

            IdentityResult result = await _repo.RegisterUser(userModel);

            System.Web.Http.IHttpActionResult errorResult = GetErrorResult(result);

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

            return new Ok();
        }