public async Task<IHttpActionResult> Register(RegisterBindingModel model) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var user = new ApplicationUser { UserName = model.Username, Email = model.Email }; IdentityResult result = await this.UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return this.GetErrorResult(result); } return this.Ok(); }
private void SeedUsers(RestaurantsContext context) { var userStore = new UserStore<ApplicationUser>(context); var userManager = new ApplicationUserManager(userStore); var user = new ApplicationUser() { UserName = TestUserUsername, Email = string.Format("{0}@gmail.com", TestUserUsername) }; var userResult = userManager.CreateAsync(user, TestUserPassword).Result; if (!userResult.Succeeded) { Assert.Fail(string.Join("\n", userResult.Errors)); } }