aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/User/UserServiceExtensions.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-03-25 20:20:47 +0800
committercrupest <crupest@outlook.com>2022-03-25 20:20:47 +0800
commit34305283aca89b8b2ebacd26ad3faf859a6a78b0 (patch)
tree7eb0d518111a4714056fe50b538bc0dd6311b4e3 /BackEnd/Timeline/Services/User/UserServiceExtensions.cs
parent65b2e7f6984b8776e603bd8ae847c9e2a9bd5ad6 (diff)
downloadtimeline-34305283aca89b8b2ebacd26ad3faf859a6a78b0.tar.gz
timeline-34305283aca89b8b2ebacd26ad3faf859a6a78b0.tar.bz2
timeline-34305283aca89b8b2ebacd26ad3faf859a6a78b0.zip
Diffstat (limited to 'BackEnd/Timeline/Services/User/UserServiceExtensions.cs')
-rw-r--r--BackEnd/Timeline/Services/User/UserServiceExtensions.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/User/UserServiceExtensions.cs b/BackEnd/Timeline/Services/User/UserServiceExtensions.cs
new file mode 100644
index 00000000..82b55fba
--- /dev/null
+++ b/BackEnd/Timeline/Services/User/UserServiceExtensions.cs
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Timeline.Services.User
+{
+ public static class UserServiceExtensions
+ {
+ public static async Task ThrowIfUserNotExist(this IUserService service, long userId)
+ {
+ if (!await service.CheckUserExistenceAsync(userId))
+ {
+ throw new EntityNotExistException(EntityTypes.User,
+ new Dictionary<string, object> { ["id"] = userId });
+ }
+ }
+ }
+}