From 4e5ba11efa3d2dd1e2d3a31ec5bbdc820219c63b Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Fri, 25 Oct 2019 23:03:36 +0800 Subject: Add user detail service. --- Timeline/Services/DatabaseExtensions.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Timeline/Services/DatabaseExtensions.cs') diff --git a/Timeline/Services/DatabaseExtensions.cs b/Timeline/Services/DatabaseExtensions.cs index 8cbc8fef..140c3146 100644 --- a/Timeline/Services/DatabaseExtensions.cs +++ b/Timeline/Services/DatabaseExtensions.cs @@ -9,6 +9,8 @@ namespace Timeline.Services { internal static class DatabaseExtensions { + private static readonly UsernameValidator usernameValidator = new UsernameValidator(); + /// /// Check the existence and get the id of the user. /// @@ -17,11 +19,11 @@ namespace Timeline.Services /// Thrown if is null. /// Thrown if is of bad format. /// Thrown if user does not exist. - internal static async Task CheckAndGetUser(DbSet userDbSet, UsernameValidator validator, string username) + internal static async Task CheckAndGetUser(DbSet userDbSet, string? username) { if (username == null) throw new ArgumentNullException(nameof(username)); - var (result, message) = validator.Validate(username); + var (result, message) = usernameValidator.Validate(username); if (!result) throw new UsernameBadFormatException(username, message); -- cgit v1.2.3