aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/UserService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd/Timeline/Services/UserService.cs')
-rw-r--r--BackEnd/Timeline/Services/UserService.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/UserService.cs b/BackEnd/Timeline/Services/UserService.cs
index 2c5644cd..76c24666 100644
--- a/BackEnd/Timeline/Services/UserService.cs
+++ b/BackEnd/Timeline/Services/UserService.cs
@@ -39,6 +39,13 @@ namespace Timeline.Services
Task<User> VerifyCredential(string username, string password);
/// <summary>
+ /// Check if a user exists.
+ /// </summary>
+ /// <param name="id">The id of the user.</param>
+ /// <returns>True if exists. Otherwise false.</returns>
+ Task<bool> CheckUserExistence(long id);
+
+ /// <summary>
/// Try to get a user by id.
/// </summary>
/// <param name="id">The id of the user.</param>
@@ -188,6 +195,11 @@ namespace Timeline.Services
return await CreateUserFromEntity(entity);
}
+ public async Task<bool> CheckUserExistence(long id)
+ {
+ return await _databaseContext.Users.AnyAsync(u => u.Id == id);
+ }
+
public async Task<User> GetUser(long id)
{
var user = await _databaseContext.Users.Where(u => u.Id == id).SingleOrDefaultAsync();