Пример #1
0
        public async Task <IActionResult> Register(RegistationViewModel registationViewModel)
        {
            if (ModelState.IsValid)
            {
                AppUser user = new AppUser {
                    Email = registationViewModel.Email, UserName = registationViewModel.Email
                };
                IdentityResult result = await _userManager.CreateAsync(user, registationViewModel.Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    foreach (IdentityError error in result.Errors)
                    {
                        this.ModelState.AddModelError("", error.Description);
                    }
                }
            }
            return(View(registationViewModel));
        }
Пример #2
0
 public RegistrationWindow()
 {
     InitializeComponent();
     DataContext = new RegistationViewModel(this);
 }