namespace ECPDAL.Communication.DTOs;
///
/// A single comment/message row in TCOMMENTTHREAD. Polymorphic via ObjectTypeId+ObjectId
/// (resolved against MENTITY.ENTITYID). Threaded via ParentCommentThreadId, with
/// RootCommentThreadId denormalized for fast whole-tree fetch (see plan's "New tables" section).
///
public class CommentThreadDTO
{
public int CommentThreadId { get; set; }
public int ParentCommentThreadId { get; set; } = -1;
public int RootCommentThreadId { get; set; }
public int ObjectTypeId { get; set; }
public int ObjectId { get; set; }
public int UserId { get; set; }
public string? UserCode { get; set; }
public string? UserName { get; set; }
public string CommentText { get; set; } = string.Empty;
public byte CommentStatus { get; set; } = 1; // 1=open 2=resolved 3=archive
public byte AccessType { get; set; } = 1; // 1=public 2=private
public int PrivateUserGroupId { get; set; } = -1;
public int SecurityMarkId { get; set; } = -1; // -> MSECURITYGROUPDETAIL.SECURITYGROUPDETAILID
public int BizTransactionId { get; set; } = -1;
public int OuId { get; set; } = -1;
public int TenantId { get; set; } = -1;
public string DatabaseName { get; set; } = string.Empty;
public byte DatabaseType { get; set; }
public short Version { get; set; }
public byte Status { get; set; } = 1; // 1=Active 2=Deleted (row-level, distinct from CommentStatus)
public int CreatedById { get; set; } = -1;
public DateTime CreatedOn { get; set; }
public int ModifiedById { get; set; } = -1;
public DateTime ModifiedOn { get; set; }
/// Populated in-memory by CommentThreadBLL when assembling a tree — never read from the DB directly.
public List Replies { get; set; } = [];
}
/// Input shape for SaveCommentThread — a smaller surface than the full read DTO.
public class SaveCommentThreadDTO
{
public int CommentThreadId { get; set; }
public int ParentCommentThreadId { get; set; } = -1;
public int ObjectTypeId { get; set; }
public int ObjectId { get; set; }
public string CommentText { get; set; } = string.Empty;
public byte AccessType { get; set; } = 1;
public int PrivateUserGroupId { get; set; } = -1;
public int SecurityMarkId { get; set; } = -1;
public int BizTransactionId { get; set; } = -1;
public int OuId { get; set; } = -1;
/// UserIds explicitly @mentioned in CommentText — drives TCOMMENTMENTION rows.
public List MentionedUserIds { get; set; } = [];
}
public class UpdateCommentThreadStatusDTO
{
public int CommentThreadId { get; set; }
public byte NewStatus { get; set; } // 1=open 2=resolved 3=archive
}
/// Flat row from MORGANIZATIONGROUPDETAIL, used by the OU-hierarchy resolver
/// (CommentThreadBLL walks ORGANISATIONGROUPPARENTID in a bounded C# loop — see plan's
/// "Access, security level & notification routing" section, OU level).
public class OrganizationGroupDetailDTO
{
public int OrganizationGroupId { get; set; }
public int OuId { get; set; } = -1;
public int OrganizationGroupParentId { get; set; } = -1;
}