Пример #1
0
        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));
        }
Пример #2
0
 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;
 }
Пример #3
0
        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;
        }
Пример #4
0
        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);
        }
Пример #5
0
 public ProfileViewModel(CFlixUser user)
 {
     this.AccountType = user.AccountType;
     this.AvatarType  = user.AvatarType;
     this.DisplayName = user.DisplayName;
 }