using System;
using Sockeye.Biz;
using System.ComponentModel.DataAnnotations;

namespace Sockeye.Models
{

    /// <summary>
    /// Event log entry
    /// </summary>
    public class Event
    {
        public long Id { get; set; }
        public uint Concurrency { get; set; }
        public DateTime Created { get; set; }
        [Required]
        public long UserId { get; set; }
        //-----------------------------------------
        [Required]
        public long SockId { get; set; }
        [Required]
        public SockType SockType { get; set; }
        [Required]
        public SockEvent SockEvent { get; set; }

        [MaxLength(255)]
        public string Textra { get; set; }


        public Event()
        {
            Created = System.DateTime.UtcNow;
        }

        public Event(long userId, long sockId, SockType sockType, SockEvent sockEvent, string textra = null)
        {
            Created = System.DateTime.UtcNow;
            UserId = userId;
            SockId = sockId;
            SockType = sockType;
            SockEvent = sockEvent;
            if (textra != null)
            {
                if (textra.Length > 255)
                    textra = textra.Substring(0, 255);
                Textra = textra;
            }
        }

        public Event(long userId, long sockId, SockType sockType, SockEvent sockEvent, DateTime created, string textra = null)
        {
            Created = created;
            UserId = userId;
            SockId = sockId;
            SockType = sockType;
            SockEvent = sockEvent;
            if (textra != null)
            {
                if (textra.Length > 255)
                    textra = textra.Substring(0, 255);
                Textra = textra;
            }
        }

    }//eoc

}//eons
