public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new CFlixUser { UserName = model.UserName, Email = model.Email, EmployeeID = Guid.NewGuid().ToString(), DisplayName = model.UserName }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); await _signInManager.SignInAsync(user, isPersistent : true); return(RedirectToLocal(returnUrl)); } AddErrors(result); } return(View(model)); }
public ProfileStatViewModel(CFlixUser user, Dictionary <EasterEgg, CFlixUserEasterEgg> userEasterEgg, bool isEditable) : base(user) { AchievementCount = userEasterEgg.Count; UnlockedAchivements = userEasterEgg.Count(pair => pair.Value != null); UserEasterEggs = userEasterEgg; IsEditable = isEditable; }
public static void UpdateWithProfileViewModel(this CFlixUser user, ProfileViewModel model) { if (model.AccountType != AccountType.User) { user.AccountType = model.AccountType; } user.AvatarType = model.AvatarType; user.DisplayName = model.DisplayName; }
private async Task <CFlixUser> CreateUser(CFlixUser usr) { if ((await _userManager.FindByNameAsync(usr.UserName)) == null) { var result = await _userManager.CreateAsync(usr); _logger.LogInformation("User {0} created", usr.UserName); } return(usr); }
public ProfileViewModel(CFlixUser user) { this.AccountType = user.AccountType; this.AvatarType = user.AvatarType; this.DisplayName = user.DisplayName; }