public async Task <bool> RegisterAsync(User user) { if (await IsExistsAsync(user.Username)) { throw new UserException("User already exist"); } user.Password = EncodePassword(user.Password); await _userDataProvider.CreateAsync(user); return(user.Id != 0); }