aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DevHive.Data/Interfaces/IUserRepository.cs6
-rw-r--r--src/DevHive.Data/Repositories/UserRepository.cs6
-rw-r--r--src/DevHive.Services/Services/PostService.cs6
-rw-r--r--src/DevHive.Services/Services/UserService.cs4
-rw-r--r--src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs7
5 files changed, 18 insertions, 11 deletions
diff --git a/src/DevHive.Data/Interfaces/IUserRepository.cs b/src/DevHive.Data/Interfaces/IUserRepository.cs
index bca8f71..b1cd0cb 100644
--- a/src/DevHive.Data/Interfaces/IUserRepository.cs
+++ b/src/DevHive.Data/Interfaces/IUserRepository.cs
@@ -12,15 +12,15 @@ namespace DevHive.Data.Interfaces
Task<bool> AddLanguageToUserAsync(User user, Language language);
Task<bool> AddTechnologyToUserAsync(User user, Technology technology);
- Task<User> GetByUsername(string username);
+ Task<User> GetByUsernameAsync(string username);
Language GetUserLanguage(User user, Language language);
IList<Language> GetUserLanguages(User user);
IList<Technology> GetUserTechnologies(User user);
Technology GetUserTechnology(User user, Technology technology);
IEnumerable<User> QueryAll();
- Task<bool> EditUserLanguage(User user, Language oldLang, Language newLang);
- Task<bool> EditUserTechnologies(User user, Technology oldTech, Technology newTech);
+ Task<bool> EditUserLanguageAsync(User user, Language oldLang, Language newLang);
+ Task<bool> EditUserTechnologiesAsync(User user, Technology oldTech, Technology newTech);
Task<bool> RemoveFriendAsync(User user, User friend);
Task<bool> RemoveLanguageFromUserAsync(User user, Language language);
diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs
index b4deacd..075ccd3 100644
--- a/src/DevHive.Data/Repositories/UserRepository.cs
+++ b/src/DevHive.Data/Repositories/UserRepository.cs
@@ -75,7 +75,7 @@ namespace DevHive.Data.Repositories
.FirstOrDefaultAsync(x => x.Id == id);
}
- public async Task<User> GetByUsername(string username)
+ public async Task<User> GetByUsernameAsync(string username)
{
return await this._context.Users
.Include(u => u.Roles)
@@ -119,7 +119,7 @@ namespace DevHive.Data.Repositories
return await RepositoryMethods.SaveChangesAsync(this._context);
}
- public async Task<bool> EditUserLanguage(User user, Language oldLang, Language newLang)
+ public async Task<bool> EditUserLanguageAsync(User user, Language oldLang, Language newLang)
{
this._context.Update(user);
@@ -129,7 +129,7 @@ namespace DevHive.Data.Repositories
return await RepositoryMethods.SaveChangesAsync(this._context);
}
- public async Task<bool> EditUserTechnologies(User user, Technology oldTech, Technology newTech)
+ public async Task<bool> EditUserTechnologiesAsync(User user, Technology oldTech, Technology newTech)
{
this._context.Update(user);
diff --git a/src/DevHive.Services/Services/PostService.cs b/src/DevHive.Services/Services/PostService.cs
index da9e76b..24ca8f3 100644
--- a/src/DevHive.Services/Services/PostService.cs
+++ b/src/DevHive.Services/Services/PostService.cs
@@ -101,7 +101,7 @@ namespace DevHive.Services.Services
return result;
}
- //Validate
+ //Validate
public async Task<bool> ValidateJwtForComment(Guid commentId, string rawTokenData)
{
Comment comment = await this._postRepository.GetCommentByIdAsync(commentId);
@@ -120,7 +120,7 @@ namespace DevHive.Services.Services
string jwtUserName = this.GetClaimTypeValues("unique_name", jwt.Claims)[0];
//List<string> jwtRoleNames = this.GetClaimTypeValues("role", jwt.Claims);
- User user = await this._userRepository.GetByUsername(jwtUserName)
+ User user = await this._userRepository.GetByUsernameAsync(jwtUserName)
?? throw new ArgumentException("User does not exist!");
return user;
@@ -137,4 +137,4 @@ namespace DevHive.Services.Services
return toReturn;
}
}
-} \ No newline at end of file
+}
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs
index 012ec1b..44cb0e2 100644
--- a/src/DevHive.Services/Services/UserService.cs
+++ b/src/DevHive.Services/Services/UserService.cs
@@ -50,7 +50,7 @@ namespace DevHive.Services.Services
if (!await this._userRepository.DoesUsernameExistAsync(loginModel.UserName))
throw new ArgumentException("Invalid username!");
- User user = await this._userRepository.GetByUsername(loginModel.UserName);
+ User user = await this._userRepository.GetByUsernameAsync(loginModel.UserName);
if (user.PasswordHash != GeneratePasswordHash(loginModel.Password))
throw new ArgumentException("Incorrect password!");
@@ -276,7 +276,7 @@ namespace DevHive.Services.Services
string jwtUserName = this.GetClaimTypeValues("unique_name", jwt.Claims)[0];
List<string> jwtRoleNames = this.GetClaimTypeValues("role", jwt.Claims);
- User user = await this._userRepository.GetByUsername(jwtUserName)
+ User user = await this._userRepository.GetByUsernameAsync(jwtUserName)
?? throw new ArgumentException("User does not exist!");
/* Username check, only when user isn't admin */
diff --git a/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs b/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
new file mode 100644
index 0000000..39868a6
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
@@ -0,0 +1,7 @@
+namespace DevHive.Data.Tests
+{
+ public class UserRepositoryTests
+ {
+
+ }
+}