Refactor ReportItem creation and encapsulate mapping

Moved mapping logic from ReportCreator.ToReportItem to a new constructor in ReportItem, improving encapsulation and simplifying report generation. Updated usings to remove unused and add necessary dependencies.
This commit is contained in:
2026-04-01 11:15:33 +02:00
parent 052da02bd0
commit 3855a8fa1e
2 changed files with 18 additions and 19 deletions

View File

@@ -1,9 +1,26 @@
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.ServiceHost.Jobs.FinalizeDocument;
public class ReportItem
{
public ReportItem() { }
public ReportItem(EnvelopeReport report, Envelope envelope)
{
CreatorFullName = envelope.User is not null
? $"{envelope.User.Prename} {envelope.User.Name}".Trim()
: string.Empty;
CreatorEmailAddress = envelope.User?.Email ?? string.Empty;
EnvelopeTitle = report.HeadTitle ?? string.Empty;
EnvelopeUuid = report.HeadUuid ?? string.Empty;
EnvelopeCertificationType = envelope.CertificationType is int certType ? ((CertificationType)certType).ToString() : "null";
ItemStatus = (EnvelopeStatus)report.PosStatus;
ItemUserReference = report.PosWho ?? string.Empty;
ItemDate = report.PosWhen ?? DateTime.MinValue;
}
// Header fields (from Envelope)
public string CreatorFullName { get; set; } = string.Empty;
public string CreatorEmailAddress { get; set; } = string.Empty;