Ejemplo n.º 1
0
 internal async Task <IdentityResult> RegisterUserAsync(PublicSignUpVM newCouple)
 {
     return(await userManager.CreateAsync(
                new MyIdentityUser
     {
         UserName = newCouple.Email,
         Email = newCouple.Email,
         FirstName1 = newCouple.FirstName1,
         FirstName2 = newCouple.FirstName2,
         WeddingDate = newCouple.WeddingDate
     },
                newCouple.Password));
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Signup(PublicSignUpVM newCouple)
        {
            if (!ModelState.IsValid)
            {
                return(View(newCouple));
            }
            else
            {
                var result = await service.RegisterUserAsync(newCouple);

                if (result.Succeeded)
                {
                    return(RedirectToAction(nameof(Login)));
                }
                else
                {
                    ModelState.AddModelError(nameof(PublicSignUpVM.Email), "Försöket misslyckades");
                    return(View(newCouple));
                }
            }
        }