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));
        }
Exemple #2
0
        public async Task <IActionResult> CreateAccount(AccountCreateVM viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(Login)));
            }

            await accountService.AddAccountAsync(viewModel);

            return(RedirectToAction(nameof(Login)));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 internal async Task AddAccountAsync(AccountCreateVM user)
 {
     await userManager.CreateAsync(new IdentityUser(user.Username), user.Password);
 }