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

namespace IWS5.DatabaseAccess.IwsDataModels;

[Table("ATWorkItem")]
[Index("WorkItemId", "LockedBy", Name = "ATWIAndLockedBy")]
[Index("Creator", "Created", Name = "ATWorkItem_Composite1")]
[Index("Creator", Name = "ATWorkItem_IX_Creator")]
[Index("LockedBy", Name = "ATWorkItem_IX_LockedBy")]
[Index("ProcessId", Name = "ATWorkitem_IX_ProcessId")]
public partial class AtworkItem
{
    [Key]
    public int WorkItemId { get; set; }

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

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

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

    public int Priority { get; set; }

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

    [Column("ATComment")]
    [StringLength(255)]
    public string? Atcomment { get; set; }

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

    [Column("ProcessID")]
    public int ProcessId { get; set; }

    public int? Expired { get; set; }

    public Guid? ObjectId { get; set; }

    [InverseProperty("WorkItem")]
    public virtual ICollection<Atdocument> Atdocuments { get; set; } = new List<Atdocument>();

    [InverseProperty("WorkItem")]
    public virtual ICollection<AtfieldInstanceDate> AtfieldInstanceDates { get; set; } = new List<AtfieldInstanceDate>();

    [InverseProperty("WorkItem")]
    public virtual ICollection<AtfieldInstanceNumber> AtfieldInstanceNumbers { get; set; } = new List<AtfieldInstanceNumber>();

    [InverseProperty("WorkItem")]
    public virtual ICollection<AtfieldInstanceString> AtfieldInstanceStrings { get; set; } = new List<AtfieldInstanceString>();

    [InverseProperty("WorkItem")]
    public virtual ICollection<AtfieldInstanceOption> AtfieldInstanceOptions { get; set; } = new List<AtfieldInstanceOption>();

    [InverseProperty("WorkItem")]
    public virtual ICollection<Atnote> Atnotes { get; set; } = new List<Atnote>();

    [InverseProperty("WorkItem")]
    public virtual ICollection<AttrackingRecord> AttrackingRecords { get; set; } = new List<AttrackingRecord>();

    [InverseProperty("WorkItem")]
    public virtual ICollection<AtworkItemReference> AtworkItemReferences { get; set; } = new List<AtworkItemReference>();

    [ForeignKey("Creator")]
    [InverseProperty("AtworkItemCreatorNavigations")]
    public virtual Atuser CreatorNavigation { get; set; } = null!;

    [ForeignKey("LockedBy")]
    [InverseProperty("AtworkItemLockedByNavigations")]
    public virtual Atuser? LockedByNavigation { get; set; }

    [ForeignKey("ProcessId")]
    [InverseProperty("AtworkItems")]
    public virtual AtprocessDefinition Process { get; set; } = null!;
}
