public UserViewModel(ApplicationUser user) { this.UserName = user.UserName; this.Age = user.Age; this.City = user.City; this.Description = user.Description; this.Email = user.Email; this.ImageUrl = user.ImageUrl; this.Tutorials = user.Tutorials.AsQueryable().Select(TutorialViewModel.FromTutorial); }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { // Create a local login before signing in the user var user = new ApplicationUser() { UserName = model.UserName, Email = model.Email, City = model.City, Age = model.Age, Description = model.Description, ImageUrl = "/Uploaded_Files/" + Properties.Settings.Default.DefaultImage }; var result = await IdentityManager.Users.CreateLocalUserAsync(user, model.Password); if (result.Success) { await IdentityManager.Authentication.SignInAsync(AuthenticationManager, user.Id, isPersistent: false); return RedirectToAction("Index", "Home"); } else { AddErrors(result); } } // If we got this far, something failed, redisplay form return View(model); }