using Microsoft.AspNetCore.Http;

namespace administration.Services
{
    public class UserSessionService : IUserSessionService
    {
        private readonly IHttpContextAccessor _httpContextAccessor;

        public UserSessionService(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor;
        }

        public int? UserId =>
            _httpContextAccessor.HttpContext?.Session.GetInt32("UserId");

        public string? UserName =>
            _httpContextAccessor.HttpContext?.Session.GetString("UserName");
    }
}
