diff options
author | crupest <crupest@outlook.com> | 2020-11-26 20:02:03 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-11-26 20:02:03 +0800 |
commit | 080330966333fe61b6a9d5413c6b05b9ea77f4dc (patch) | |
tree | 69364aa51ae18083e75b486e3ab5bb6542061860 /BackEnd/Timeline/Services/UserService.cs | |
parent | c69a18f66721404dac3a04a090d04bf248964a9f (diff) | |
download | timeline-080330966333fe61b6a9d5413c6b05b9ea77f4dc.tar.gz timeline-080330966333fe61b6a9d5413c6b05b9ea77f4dc.tar.bz2 timeline-080330966333fe61b6a9d5413c6b05b9ea77f4dc.zip |
feat: Add highlight timeline entity and service.
Diffstat (limited to 'BackEnd/Timeline/Services/UserService.cs')
-rw-r--r-- | BackEnd/Timeline/Services/UserService.cs | 12 |
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();
|