Exemplo n.º 1
0
        public async Task<IdentityResult> RegisterUserAsync(UserModel userModel)
        {
            var user = new IdentityUser
            {
                UserName = userModel.UserName
            };

            return await _userManager.CreateAsync(user, userModel.Password);
        }
Exemplo n.º 2
0
        public async Task<IHttpActionResult> Register(UserModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var result = await _repo.RegisterUserAsync(userModel);

            if (result == null) return InternalServerError();
            if (result.Errors != null && result.Errors.Any()) return BadRequest(string.Concat(result.Errors));

            return Ok();
        }