using DbController;

namespace Tabletop.Core.Models
{
    public enum DeviceType
    {
        Desktop,
        Tablet,
        Smartphone,
        Other
    }

    public enum OperatingSystem
    {
        Windows,
        macOS,
        Linux,
        iOS,
        Android,
        Other
    }

    public class ConnectionLog
    {
        [CompareField("ip_address")]
        public string IpAddress { get; set; } = string.Empty;                           // IP-Adresse des Besuchers
        [CompareField("connection_time")]
        public DateTime ConnectionTime { get; set; }                                    // Zeitstempel des Zugriffs
        [CompareField("user_agent")]
        public string UserAgent { get; set; } = string.Empty;                           // User-Agent (Browser/OS)
        [CompareField("referrer")]
        public string Referrer { get; set; } = string.Empty;                            // Referrer (URL der vorherigen Seite)
        [CompareField("requested_url")]
        public string RequestedUrl { get; set; } = string.Empty;                        // Angeforderte URL
        [CompareField("geolocation")]
        public string? Geolocation { get; set; } = null;                                // Geografische Lage (optional, kann null sein)
        [CompareField("session_id")]
        public string SessionId { get; set; } = string.Empty;                           // Sitzungs-ID
        [CompareField("status_code")]
        public int StatusCode { get; set; }                                             // HTTP-Statuscode der Antwort
        [CompareField("device_type")]
        public string DeviceType { get; set; } = string.Empty;                          // Gerätetyp (Desktop/Tablet/Smartphone)
        [CompareField("operating_system")]
        public string OperatingSystem { get; set; } = string.Empty;                     // Betriebssystem des Besuchers

        public Dictionary<string, object?> GetParameters()
        {
            return new Dictionary<string, object?>
            {
                { "IP_ADDRESS", IpAddress },
                { "CONNECTION_TIME", ConnectionTime },
                { "USER_AGENT", UserAgent },
                { "REFERRER", Referrer },
                { "REQUESTED_URL", RequestedUrl },
                { "GEOLOCATION", Geolocation },
                { "SESSION_ID", SessionId },
                { "STATUS_CODE", StatusCode },
                { "DEVICE_TYPE", DeviceType },
                { "OPERATING_SYSTEM", OperatingSystem }
            };
        }
    }
}
