diff options
| author | transtrike <transtrike@gmail.com> | 2020-12-18 10:11:48 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2020-12-18 10:11:48 +0200 |
| commit | 12408f43a7a954042358196ee080439aa7aed700 (patch) | |
| tree | c4e02d6d571eff32b8e05c97f36ce7a2e18f3baf | |
| parent | 323e0ba9d83b503496633fa75ce66eca1fac265c (diff) | |
| download | DevHive-12408f43a7a954042358196ee080439aa7aed700.tar DevHive-12408f43a7a954042358196ee080439aa7aed700.tar.gz DevHive-12408f43a7a954042358196ee080439aa7aed700.zip | |
Removed IsUsernameValid
| -rw-r--r-- | src/DevHive.Data/Repositories/UserRepository.cs | 7 | ||||
| -rw-r--r-- | src/DevHive.Services/Services/UserService.cs | 4 |
2 files changed, 2 insertions, 9 deletions
diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs index 6d14a65..5cd4264 100644 --- a/src/DevHive.Data/Repositories/UserRepository.cs +++ b/src/DevHive.Data/Repositories/UserRepository.cs @@ -86,13 +86,6 @@ namespace DevHive.Data.Repositories .Any(x => x.Id == id); } - public Task<bool> IsUsernameValid(string username) - { - return this._context - .Set<User>() - .AnyAsync(u => u.UserName == username); - } - public bool DoesUserHaveThisUsername(Guid id, string username) { return this._context diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs index af8a6f0..134a142 100644 --- a/src/DevHive.Services/Services/UserService.cs +++ b/src/DevHive.Services/Services/UserService.cs @@ -32,7 +32,7 @@ namespace DevHive.Services.Services public async Task<TokenModel> LoginUser(LoginServiceModel loginModel) { - if (!await this._userRepository.IsUsernameValid(loginModel.UserName)) + if (!await this._userRepository.DoesUsernameExist(loginModel.UserName)) throw new ArgumentException("Invalid username!"); User user = await this._userRepository.GetByUsername(loginModel.UserName); @@ -81,7 +81,7 @@ namespace DevHive.Services.Services throw new ArgumentException("User does not exist!"); if (!this._userRepository.DoesUserHaveThisUsername(updateModel.Id, updateModel.UserName) - && await this._userRepository.IsUsernameValid(updateModel.UserName)) + && await this._userRepository.DoesUsernameExist(updateModel.UserName)) throw new ArgumentException("Username already exists!"); User user = this._userMapper.Map<User>(updateModel); |
