using FrameworkDAL.CustomCode.EIPConversation.EIPSessionAdmin; using FrameworkDAL.DTO.EIPConversation; using GB5Shared.DTO.Framework.Login; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace FrameworkBLL.EIPConversation.EIPAdmin.EIPSessionAdmin { public class EIPSessionAdminBLL : IEIPSessionAdminBLL { private readonly IEIPSessionAdminDAL _dal; private readonly ILogger _logger; public EIPSessionAdminBLL( IEIPSessionAdminDAL dal, ILogger logger) { _dal = dal ?? throw new ArgumentNullException(nameof(dal)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task> GetSessionListAsync( string? status, int? channelType, DateTime? fromDate, DateTime? toDate, LoginDTO login, CancellationToken ct = default) { try { // Normalise status to uppercase var normStatus = status?.Trim().ToUpperInvariant(); if (normStatus != null && normStatus != "ACTIVE" && normStatus != "EXPIRED") throw new ArgumentException("Status must be ACTIVE or EXPIRED (or omit to return all)."); _logger.LogInformation( "BLL | GetSessionList | Tenant={TenantId} | Status={Status} | ChannelType={ChannelType}", login.ClientId, normStatus, channelType); return await _dal.GetSessionListAsync( normStatus, channelType, fromDate, toDate, login, ct) .ConfigureAwait(false); } catch (Exception ex) { _logger.LogError(ex, "BLL | GetSessionList | Error | Tenant={TenantId}", login.ClientId); throw; } } } }