namespace PowderCoating.Core.Entities; /// /// Platform-level community library entry for a shared custom formula template. /// Not tenant-scoped — no BaseEntity, no CompanyId, no soft delete. /// Shared voluntarily by the originating company; imported as independent copies by others. /// public class FormulaLibraryItem { public int Id { get; set; } // ── Formula content (copied from CustomItemTemplate at share time) ───── public string Name { get; set; } = string.Empty; public string? Description { get; set; } /// "FixedRate" or "SurfaceAreaSqFt" — mirrors CustomItemTemplate.OutputMode. public string OutputMode { get; set; } = "FixedRate"; /// JSON array of field definitions: [{name, label, unit, defaultValue}] public string FieldsJson { get; set; } = "[]"; /// NCalc expression using field name slugs and the reserved variable 'rate'. public string Formula { get; set; } = string.Empty; public decimal? DefaultRate { get; set; } public string? RateLabel { get; set; } public string? Notes { get; set; } /// /// Blob path referencing the source template's diagram image. /// Nulled out (here and on all imports) if the source template's diagram is removed. /// public string? DiagramImagePath { get; set; } // ── Attribution ──────────────────────────────────────────────────────── /// Comma-separated community tags, e.g. "HVAC,Sheet Metal". public string? Tags { get; set; } /// Optional industry hint shown on the browse card, e.g. "HVAC", "Automotive". public string? IndustryHint { get; set; } /// Id of the CustomItemTemplate this was shared from. public int SourceCustomItemTemplateId { get; set; } public int SourceCompanyId { get; set; } /// Denormalized company name so it renders without a join when the company is gone. public string SourceCompanyName { get; set; } = string.Empty; /// /// When non-null, this entry was derived from an imported formula that was subsequently /// modified. Points to the original library entry. Shown as "Inspired by..." on the browse card. /// public int? InspiredByFormulaLibraryItemId { get; set; } public virtual FormulaLibraryItem? InspiredBy { get; set; } public string SharedByUserId { get; set; } = string.Empty; public DateTime SharedAt { get; set; } = DateTime.UtcNow; /// False when the creator has removed it from the community library. public bool IsPublished { get; set; } = true; /// Running count of how many companies have imported this entry. public int ImportCount { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime? UpdatedAt { get; set; } }