Exemple #1
0
        public bool Insert(RegisterModel model, IValidationDictionary validation)
        {
            ValidateNewUser(model, validation);

            if (validation.IsValid)
            {
                var salt = GenerateSalt(20);

                var user = new User
                {
                    UserName = model.UserName,
                    PasswordSalt = salt,
                    Password = HashPassword(model.Password, salt),
                    Email = model.Email,
                    DisplayName = model.DisplayName
                };

                _context.Users.Add(user);
                return true;
            }

            return false;
        }
Exemple #2
0
 public void Update(User user)
 {
     _context.Entry(user).State = EntityState.Modified;
 }