using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Entities.Base.History.Base;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PARR.Domain.Entities
{
    [Table("TemplateHistories")]
    public class TemplateHistory : IBaseEntity, ITemplateGeneralProps, IHistoryInitiator, IHistoryTable
    {
        [Key]
        public Guid Id { get; set; }


        public Guid ParentId { get; set; }

        public DateTimeOffset DateAddedToHistory { get; set; }

        public string? InitiatorIp { get; set; }

        public ParrComponentsEnum? InitiatorParrComponentId { get; set; }

        public string? InitiatorComment { get; set; }


        [NotMapped]
        public DateTimeOffset DateCreated { get; set; }

        public DateTimeOffset? DateModified { get; set; }

        public required string Name { get; set; }

        public bool IsActiveTemplate { get; set; }

        public bool IsActiveSchedule { get; set; }

        public DateTimeOffset? LastRun { get; set; }

        public DateTimeOffset NextRun { get; set; }

        public TemplateStatusTypeEnum StatusTypeId { get; set; } = TemplateStatusTypeEnum.Used;

        public string? ScheduleEsppId { get; set; }


        [ForeignKey(nameof(ParentId))]
        public Template? Template { get; set; }


    }
}
