Пример #1
0
        public async Task<IHttpActionResult> AddUser([FromBody] RegisterModel model)
        {
            var user = new ApplicationUser();
            user.ApplyChanges(model);

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

            if (result.Succeeded)
            {
                return Ok("Registered");
            }

            return new BadRequestResult(new HttpRequestMessage(HttpMethod.Post, result.Errors.ToString()));
        }
        public async Task<IHttpActionResult> Register(RegisterModel model)
        {
            var user = new ApplicationUser();
            user.ApplyChanges(model);

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

            if (result.Succeeded)
            {
                return Ok("Registered");
            }

            var errors = result.Errors.Aggregate("", (current, error) => $"{current}\r\n{error}");

            return BadRequest(errors);
        }