Beispiel #1
0
 public static User ConvertToUser(RegisterModel model)
 {
     return new User
     {
         Email = model.Email,
         Login = model.Login,
         LastName = model.LastName,
         FirstName = model.FirstName,
         Password = model.Password
     };
 }
 public async Task<ActionResult> Register(RegisterModel model)
 {
     if (ModelState.IsValid)
     {
         var user = new CustomIdentityUser(RegisterModel.ConvertToUser(model));
         var result = await UserManager.CreateAsync(user, model.Password);
         if (result.Succeeded)
         {
             var createdUser = RepositoryManager.Instance.UserRepository.GetByLogin(model.Login);
             if (createdUser != null)
             {
                 await SignInManager.SignInAsync(new CustomIdentityUser(createdUser), isPersistent: false, rememberBrowser: false);
             }
             return RedirectToAction("Index", "Home");
         }
         AddErrors(result);
     }
     return View(model);
 }