Beispiel #1
0
        public RegisterErrors Register(User newUser)
        {
            var errors = RegisterErrors.None;

            if(_context.Users.Any(user => user.Username == newUser.Username))
            {
                errors |= RegisterErrors.UsernameTaken;
            }

            if(_context.Users.Any(user => user.Email == newUser.Email))
            {
                errors |= RegisterErrors.EmailTaken;
            }

            if (errors == RegisterErrors.None)
            {
                _context.Users.Add(newUser);
                try
                {
                    _context.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    errors |= RegisterErrors.DataBaseError;
                }
                catch (DbEntityValidationException)
                {
                    errors |= RegisterErrors.DataBaseError;
                }
            }

            return errors;
        }
Beispiel #2
0
 public void RegisterUser(User user)
 {
 }