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

namespace IWS5.DatabaseAccess.IwsDataModels;

[Table("ATScheduledItem")]
[Index("Name", Name = "UQ_ATScheduledItem_Name", IsUnique = true)]
public partial class AtscheduledItem
{
    [Key]
    public int ScheduleId { get; set; }

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

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

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

    public bool Enabled { get; set; }

    public bool WaitForCompletion { get; set; }

    public int? Priority { get; set; }

    public int ScheduleTypeId { get; set; }

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

    public DateTime? StartTime { get; set; }

    public DateTime? ExpireTime { get; set; }

    public int StatusId { get; set; }

    public int? LastRunStatusId { get; set; }

    public DateTime? LastRun { get; set; }

    public DateTime CreatedAt { get; set; }

    public DateTime UpdatedAt { get; set; }

    [ForeignKey("ServerHost")]
    [InverseProperty("AtscheduledItems")]
    public virtual Atserver Server { get; set; } = null!;

    [InverseProperty("Schedule")]
    public virtual ICollection<AtscheduledTask> AtscheduledTasks { get; set; } = new List<AtscheduledTask>();

    [ForeignKey("LastRunStatusId")]
    [InverseProperty("AtscheduledItems")]
    public virtual AtrunStatusType? LastRunStatus { get; set; }

    [ForeignKey("ScheduleTypeId")]
    [InverseProperty("AtscheduledItems")]
    public virtual AtscheduleType ScheduleType { get; set; } = null!;

    [ForeignKey("StatusId")]
    [InverseProperty("AtscheduledItems")]
    public virtual AtscheduleStatusType Status { get; set; } = null!;
}
