Backend/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityTask.cs

66 lines
1.9 KiB
C#

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 eSuite.Core.Enums;
using Microsoft.EntityFrameworkCore;
namespace e_suite.Database.Core.Tables.Activity;
[DisplayName("Activity")]
[Table("ActivityTasks", Schema = "Activity")]
[Index(nameof(Guid), IsUnique = true)]
[Index(nameof(ActivityId), nameof(ActivityOrdinal), IsUnique = true)]
public class ActivityTask : IGeneralId, ISoftDeletable
{
[Key]
public long Id { get; set; }
public Guid Guid { get; set; }
public long? ParentId { get; set; }
public long ActivityId { get; set; }
public long ActivityOrdinal { get; set; }
/// <summary>
/// This is the guid of the task from the workflow template
/// </summary>
[Required]
public Guid TaskGuid { get; set; }
[AuditName]
[Required]
public string TaskName { get; set; }
public ActivityState ActivityState { get; set; } = ActivityState.Pending;
/// <summary>
/// Contains the date and time when the task was changed from Pending to Active
/// </summary>
public DateTimeOffset? StartDateTime { get; set; }
/// <summary>
/// Contains the date and time when the task was changed from Active to Completed
/// </summary>
public DateTimeOffset? FinishDateTime { get; set; }
[AuditSoftDelete(true)]
[Required]
[DefaultValue(false)]
public bool Deleted { get; set; }
[AuditLastUpdated]
public DateTimeOffset LastUpdated { get; set; }
[ForeignKey(nameof(ActivityId))]
public virtual Activity Activity { get; set; } = null!;
[ForeignKey(nameof(ParentId))]
public virtual ActivityTask ParentTask { get; set; } = null!;
public ICollection<ActivityTask> Tasks { get; set; } = [];
}