using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace IWS5.DatabaseAccess.IwsDataModels;

[Table("ATTemplates")]
[Index("DocumentCabinetId", Name = "IX_ATTemplates_DocumentCabinetId")]
[Index("ProcessId", Name = "IX_ATTemplates_ProcessId")]
[Index("ObjectId", Name = "UK_ATTemplates_ObjectId", IsUnique = true)]
public partial class Attemplate
{
    [Key]
    public int Id { get; set; }

    [StringLength(255)]
    public string Name { get; set; } = null!;

    [StringLength(255)]
    public string? Description { get; set; }

    public int? ProcessId { get; set; }

    public int? DocumentCabinetId { get; set; }

    public int TemplateTypeId { get; set; }

    public int? DbConnectionId { get; set; }

    [StringLength(50)]
    public string? DbName { get; set; }

    public Guid ObjectId { get; set; }

    [Column(TypeName = "datetime")]
    public DateTime CreateDate { get; set; }

    [Column(TypeName = "datetime")]
    public DateTime ModifyDate { get; set; }

    public int? HierarchyId { get; set; }

    [InverseProperty("Template")]
    public virtual ICollection<AtconvertEvent> AtconvertEvents { get; set; } = new List<AtconvertEvent>();

    [InverseProperty("Template")]
    public virtual ICollection<AteventTriggerDefinition> AteventTriggerDefinitions { get; set; } = new List<AteventTriggerDefinition>();

    [InverseProperty("Template")]
    public virtual ICollection<AteventTriggerTemplate> AteventTriggerTemplates { get; set; } = new List<AteventTriggerTemplate>();

    [InverseProperty("Template")]
    public virtual ICollection<AtexportDefinition> AtexportDefinitions { get; set; } = new List<AtexportDefinition>();

    [InverseProperty("Template")]
    public virtual ICollection<AtexportEvent> AtexportEvents { get; set; } = new List<AtexportEvent>();

    [InverseProperty("Template")]
    public virtual ICollection<AtexternalTrackingDefinition> AtexternalTrackingDefinitions { get; set; } = new List<AtexternalTrackingDefinition>();

    [InverseProperty("Template")]
    public virtual ICollection<AttrackingDefinitionTemplate> AttrackingDefinitionTemplates { get; set; } = new List<AttrackingDefinitionTemplate>();

    [InverseProperty("Template")]
    public virtual ICollection<AtxmlTemplateDefinition> AtxmlTemplateDefinitions { get; set; } = new List<AtxmlTemplateDefinition>();

    [ForeignKey("DbConnectionId")]
    [InverseProperty("Attemplates")]
    public virtual Atconnection? DbConnection { get; set; }

    [ForeignKey("DocumentCabinetId")]
    [InverseProperty("Attemplates")]
    public virtual AtdocumentCabinet? DocumentCabinet { get; set; }

    [ForeignKey("HierarchyId")]
    [InverseProperty("Attemplates")]
    public virtual AtxmlHierarchy? Hierarchy { get; set; }

    [ForeignKey("ProcessId")]
    [InverseProperty("Attemplates")]
    public virtual AtprocessDefinition? Process { get; set; }

    [ForeignKey("TemplateTypeId")]
    [InverseProperty("Attemplates")]
    public virtual AttemplateType TemplateType { get; set; } = null!;
}
