public async Task <IActionResult> CreateAccount([FromBody] AccountCreateVM accountCreateVM) { Response response = await _mediator.Send(new CreateAccount() { AccountCreateVM = accountCreateVM }); return(CreatedAtAction("GetAccountById", new { id = (response.Data as AccountVM).Id }, response)); }
public async Task <IActionResult> CreateAccount(AccountCreateVM viewModel) { if (!ModelState.IsValid) { return(View(nameof(Login))); } await accountService.AddAccountAsync(viewModel); return(RedirectToAction(nameof(Login))); }
public async Task <IActionResult> Create(AccountCreateVM model) { if (!ModelState.IsValid) { return(View(model)); } if (await accountRepository.AddNewUserAsync(model.CreateForm)) { await accountRepository.TryLoginAsync(new AccountLoginVM { Username = model.CreateForm.Username, Password = model.CreateForm.Password }); if (model.ReturnUrl == null) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } return(Redirect(model.ReturnUrl)); } return(View(model)); }
internal async Task AddAccountAsync(AccountCreateVM user) { await userManager.CreateAsync(new IdentityUser(user.Username), user.Password); }