Skip to content

Application Services ​

Common service abstractions for application layer.

ICurrentUserService ​

Access to current authenticated user context.

MemberTypeDescription
UserIdGuid?Current user ID
Emailstring?Current user email
IsAuthenticatedboolIs user authenticated
UserClaimsPrincipal?Full claims principal
IsInRole(string)boolCheck role membership
HasPermission(string)boolCheck permission
GetRoles()IEnumerable<string>All user roles
GetPermissions()IEnumerable<string>All user permissions
GetClientIpAddress()string?Client IP
GetUserAgent()string?User agent string

IDateTimeService ​

Testable date/time abstraction.

MemberTypeDescription
UtcNowDateTimeCurrent UTC time
NowDateTimeCurrent local time
TodayDateOnlyCurrent UTC date

Implementation ​

csharp
public sealed class SystemDateTimeService : IDateTimeService
{
    public DateTime UtcNow => DateTime.UtcNow;
    public DateTime Now => DateTime.Now;
    public DateOnly Today => DateOnly.FromDateTime(DateTime.UtcNow);
}

Released under the MIT License.