public async Task <ActionResult> CreateAdmin(CreateAdminVM vm) { if (ModelState.IsValid) { return(Ok()); } return(BadRequest()); }
public async Task <IActionResult> CreateAdmin(CreateAdminVM viewModel) { if (ModelState.IsValid) { await context.CreateAdmin(viewModel); return(RedirectToAction(nameof(AdminController.CreateAdmin))); } else { return(View(viewModel)); } }
public async Task CreateAdmin(CreateAdminVM viewModel) { var tempUser = new IdentityUser(viewModel.UserName); var result = await userManager.CreateAsync(tempUser, viewModel.Password); if (result.Succeeded) { var newUser = new Users { Id = tempUser.Id, FirstName = viewModel.FirstName, LastName = viewModel.LastName, Email = viewModel.UserName, Category = viewModel.Category }; this.Users.Add(newUser); await this.SaveChangesAsync(); } }