public async Task <IActionResult> Post([FromBody] RegistrationModelComplete model) { var newUser = new ApplicationUser { UserName = model.UserName, Email = model.Email, PhoneNumber = model.PhoneNumber, FirstName = model.FirstName, LastName = model.LastName, AddressLine = model.AddressLine, PostalCode = model.PostalCode, Town = model.Town }; newUser.SecurityStamp = Guid.NewGuid().ToString(); var result = await _userManager.CreateAsync(newUser, model.Password); if (!result.Succeeded) { var errors = result.Errors.Select(x => x.Description); return(BadRequest(new RegistrationResult { Successful = false, Errors = errors })); } return(Ok(new RegistrationResult { ID = newUser.ID, Successful = true })); }
public async Task <RegistrationResult> CreateEmployee(RegistrationModelComplete model) { await loadAuthTask; var content = JsonSerializer.Serialize(model); var response = await _httpClient.PostAsync($"api/CreateUser", new StringContent(content, Encoding.UTF8, "application/json")); var text = await response.Content.ReadAsStringAsync(); var output = JsonSerializer.Deserialize <RegistrationResult>(text, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); return(output); }