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

namespace IWS5.DatabaseAccess.IwsDataModels;

[Table("ATWorkItemReference")]
[Index("WorkItemReferenceId", "WorkItemId", Name = "ATWIAndATWIRef")]
[Index("EventId", "Expired", "ServerRequest", "Status", Name = "ATWorkItemReferenceEventExpiredAndServer")]
[Index("EventId", "ExpirationTime", "Expired", "ServerRequest", "Status", Name = "ATWorkItemReferenceEventExpiredAndServerAndExpireDate")]
[Index("WorkItemId", "ArrivalDate", "EventId", "Expired", "ServerRequest", "Status", "Priority", Name = "ATWorkItemReferenceEventExpiredAndServerWithOrder")]
[Index("QueueId", "SourceQueueId", "ServerRequest", Name = "ATWorkItemReference_Composite1")]
[Index("SourceUser", "ServerRequest", Name = "ATWorkItemReference_Composite2")]
[Index("AssignedTo", Name = "ATWorkItemReference_IX_AssignedTo")]
[Index("EventId", Name = "ATWorkItemReference_IX_EventId")]
[Index("QueueId", Name = "ATWorkItemReference_IX_Queue")]
[Index("SourceQueueId", Name = "ATWorkItemReference_IX_SQueue")]
[Index("Successor", Name = "ATWorkItemReference_IX_Sucesor")]
[Index("WorkItemId", Name = "ATWorkItemReference_IX_WIId")]
public partial class AtworkItemReference
{
    [Key]
    public int WorkItemReferenceId { get; set; }

    public int WorkItemId { get; set; }

    public int? QueueId { get; set; }

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

    public int? SourceQueueId { get; set; }

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

    [Column("EventID")]
    public int? EventId { get; set; }

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

    public int Expired { get; set; }

    public int? Successor { get; set; }

    public int? ServerRequest { get; set; }

    public int? ServerRequestParam { get; set; }

    public int Status { get; set; }

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

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

    public int? PendEventId { get; set; }

    public int? PendQueueId { get; set; }

    public int? Draft { get; set; }

    public int? Priority { get; set; }

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

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

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

    [ForeignKey("AssignedTo")]
    [InverseProperty("AtworkItemReferenceAssignedToNavigations")]
    public virtual Atuser? AssignedToNavigation { get; set; }

    [InverseProperty("WorkItemReference")]
    public virtual AtexceptionNote? AtexceptionNote { get; set; }

    [InverseProperty("PendingWorkItemReference")]
    public virtual AtpendingWorkItemReference? AtpendingWorkItemReference { get; set; }

    [InverseProperty("SourceWorkItemRefNavigation")]
    public virtual ICollection<Atsplit> AtsplitSourceWorkItemRefNavigations { get; set; } = new List<Atsplit>();

    [InverseProperty("SplitWorkItemRefNavigation")]
    public virtual Atsplit? AtsplitSplitWorkItemRefNavigation { get; set; }

    [InverseProperty("WorkItemRefNavigation")]
    public virtual ICollection<Atstack> Atstacks { get; set; } = new List<Atstack>();

    [InverseProperty("WorkItemReference")]
    public virtual ICollection<AttaskInstance> AttaskInstances { get; set; } = new List<AttaskInstance>();

    [ForeignKey("EventId")]
    [InverseProperty("AtworkItemReferenceEvents")]
    public virtual AteventDefinition? Event { get; set; }

    [ForeignKey("QueueId")]
    [InverseProperty("AtworkItemReferenceQueues")]
    public virtual Atqueue? Queue { get; set; }

    [ForeignKey("SourceQueueId")]
    [InverseProperty("AtworkItemReferenceSourceQueues")]
    public virtual Atqueue? SourceQueue { get; set; }

    [ForeignKey("SourceUser")]
    [InverseProperty("AtworkItemReferenceSourceUserNavigations")]
    public virtual Atuser? SourceUserNavigation { get; set; }

    [ForeignKey("Successor")]
    [InverseProperty("AtworkItemReferenceSuccessorNavigations")]
    public virtual AteventDefinition? SuccessorNavigation { get; set; }

    [ForeignKey("WorkItemId")]
    [InverseProperty("AtworkItemReferences")]
    public virtual AtworkItem WorkItem { get; set; } = null!;
}
