using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using e_suite.Database.Audit.Attributes;
using e_suite.Database.Core.Models;
using e_suite.Database.Core.Tables.Workflow;
using eSuite.Core.Enums;
using Microsoft.EntityFrameworkCore;

namespace e_suite.Database.Core.Tables.Activity;

[DisplayName("Activity")]
[Table("Activities", Schema = "Activity")]
[Index(nameof(Name), IsUnique = true)]
[Index(nameof(Guid), IsUnique = true)] 
public class Activity : IGeneralId, ISoftDeletable
{
    [Key]
    public long Id { get; set; }
    public Guid Guid { get; set; }

    [AuditName]
    [Required]
    public string Name { get; set; } = string.Empty;

    [Required]
    public long WorkflowVersionId { get; set; }

    [Required]
    public ActivityState ActivityState { get; set; } = ActivityState.Pending;

    [AuditSoftDelete(true)]
    [Required]
    [DefaultValue(false)]
    public bool Deleted { get; set; }

    [AuditLastUpdated]
    public DateTimeOffset LastUpdated { get; set; }


    [ForeignKey(nameof(WorkflowVersionId))]
    public virtual WorkflowVersion WorkflowVersion { get; set; } = null!;

    public ICollection<ActivityTask> Tasks { get; set; } = [];
}