public async Task<ActionResult> Subscribe(SignupViewModel signupViewModel) { // Add new User // Check if User already exists var usernames = AspNetUserService.GetAllUsers().Select(x => x.UserName); if (usernames.Contains(signupViewModel.UserName)) { // it means username is already taken TempData["message"] = new MessageViewModel { Message = "", IsError = true }; return View(signupViewModel); } var user = new AspNetUser { UserName = signupViewModel.UserName, Email = signupViewModel.Email }; user.EmailConfirmed = true; if (!String.IsNullOrEmpty(signupViewModel.Password)) { var result = await UserManager.CreateAsync(user, signupViewModel.Password); if (result.Succeeded) { return RedirectToAction("Index", "Home"); } } return View(signupViewModel); }
public ActionResult Subscribe() { SignupViewModel signupViewModel = new SignupViewModel(); return View(signupViewModel); }