Exemplo n.º 1
0
        public User Register(User user)
        {
            if (_dbContext.Users.Any(x => x.Username == user.Username))
            {
                throw new AppException("Username \"" + user.Username + "\" is already taken");
            }
            user.Password = HashUtils.GetHashString(user.Password);
            _dbContext.Users.Add(user);
            _dbContext.SaveChanges();

            return(user);
        }