From a672e10faad434899d81ef9d0d0d5adbbc7841da Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 30 Apr 2021 16:52:55 +0800 Subject: refactor: ... --- .../Services/User/BasicUserServiceExtensions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 BackEnd/Timeline/Services/User/BasicUserServiceExtensions.cs (limited to 'BackEnd/Timeline/Services/User/BasicUserServiceExtensions.cs') diff --git a/BackEnd/Timeline/Services/User/BasicUserServiceExtensions.cs b/BackEnd/Timeline/Services/User/BasicUserServiceExtensions.cs new file mode 100644 index 00000000..8a05f452 --- /dev/null +++ b/BackEnd/Timeline/Services/User/BasicUserServiceExtensions.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Timeline.Services.User +{ + public static class BasicUserServiceExtensions + { + public static async Task ThrowIfUserNotExist(this IBasicUserService service, long userId) + { + if (!await service.CheckUserExistenceAsync(userId)) + { + throw new EntityNotExistException(EntityTypes.User, + new Dictionary { ["id"] = userId }); + } + } + } +} -- cgit v1.2.3