Пример #1
0
        public async Task <IActionResult> RegisterPatient([FromBody] RegisterPatientVm model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName             = model.Email,
                    Email                = model.Email,
                    FirstName            = model.FirstName,
                    LastName             = model.LastName,
                    IsActive             = true,
                    DateModifiedIfActive = DateTime.UtcNow
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddClaimAsync(user, new Claim("IsPatient", "true"));

                    var userViewModel = _service.CreateRegisteredPatient(model);
                    return(Ok(userViewModel));
                }
                AddErrors(result);
            }
            // If we got this far, something failed
            return(BadRequest(this.ModelState));
        }