πŸ“„ DocumentAttribute Class Documentation


Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Key Functional Areas
  4. Data Model
  5. Entity Framework Mappings
  6. Property Reference
  7. UML Class Diagram
  8. Sample Code Blocks & Usage Examples
  9. Conclusion

Overview & Purpose

The DocumentAttribute class is a domain entity representing a metadata attribute associated with documents in the Irby Imaging system. It provides:

  • A unique identifier and audit fields (created/modified info).
  • Flexible attribute types (text, date, number, etc.) via the AttributeType enum.
  • Categorization flags (Safety, Legal, IT, HR, Accounting, Bidding).
  • Multi-value support, linking to other domain entities (Employee, Job, Customer), and availability control.

This class is used by Entity Framework (EF) to map to the irby.DocumentAttribute table in the database schema.


Dependencies & Technologies

  • .NET Core / .NET Framework
  • Entity Framework Core (Code-First)
  • Namespaces:
    • System
    • System.ComponentModel.DataAnnotations
    • System.ComponentModel.DataAnnotations.Schema

Key Functional Areas

  • 🎯 Identification & Auditing
  • 🏷️ Attribute Definition (Name, Type, Allowed Values)
  • πŸ”– Categorization (Safety, Legal, HR, IT, Accounting, Bidding)
  • πŸ”— Data Linking to Employee, Job, Customer
  • βœ”οΈ Availability & Requirement flags
  • βš™οΈ Entity Framework Mappings

Data Model

DocumentAttribute Class

namespace IrbyImaging.DomainClasses
{
    [Table("DocumentAttribute", Schema = "irby")]
    public class DocumentAttribute
    {
        [Key]
        public Guid Id { get; set; }

        public string AttributeName { get; set; }
        public AttributeType AttributeType { get; set; }
        public bool IsMultiValue { get; set; }

        // Category Flags
        public bool IsSafety { get; set; }
        public bool IsLegalDocument { get; set; }
        public bool IsIT { get; set; }
        public bool IsAccounting { get; set; }
        public bool IsBidding { get; set; }
        public bool IsHR { get; set; }

        // Other metadata
        public ImagingType ImagingType { get; set; }
        public string Values { get; set; }
        public string DocumentType { get; set; }

        // Workflow & Visibility
        public bool IsAvailable { get; set; }
        public bool IsDeleted { get; set; }
        public bool IsRequired { get; set; }

        // Linking flags
        public bool LinkEmployeeData { get; set; }
        public bool LinkJobData { get; set; }
        public bool LinkCustomerData { get; set; }

        // Audit fields
        [Display(Name = "Added By")]
        public string AddedBy { get; set; }

        [Display(Name = "Added Date")]
        public DateTime AddedDate { get; set; }

        [Display(Name = "Modified By")]
        public string ModifiedBy { get; set; }

        [Display(Name = "Modified Date")]
        public DateTime ModifiedDate { get; set; }
    }
}

AttributeType Enum

namespace IrbyImaging.DomainClasses
{
    public enum AttributeType
    {
        Date,
        Text,
        Character,
        Boolean,
        Number,
        Currency
    }
}
Value Description
Date Represents a date/time attribute
Text Free-form text
Character Single character
Boolean True/False
Number Numeric value
Currency Monetary amount

Entity Framework Mappings

Attribute Target
[Table] Maps class to irby.DocumentAttribute
[Key] Marks Id as the primary key
[Display] UI-friendly labels for auditing fields

Property Reference

Property Type Description
Id Guid Unique identifier (PK).
AttributeName string Name/key of the attribute.
AttributeType AttributeType Data type of the attribute.
IsMultiValue bool True if the attribute can hold multiple values.
IsSafety bool Marks this as a Safety-related attribute.
IsLegalDocument bool Marks this as a Legal document attribute.
IsIT bool Marks this as IT-related.
IsAccounting bool Marks this as Accounting-related.
IsBidding bool Marks this as related to Bidding processes.
IsHR bool Marks this as HR-related.
ImagingType ImagingType (External enum) Indicates imaging classification.
Values string Pipe‑separated or JSON-encoded allowed values (for drop-downs, etc.).
DocumentType string Category/type of document to which this attribute applies.
IsAvailable bool Visibility/enablement in UI or processing.
IsDeleted bool Soft-delete indicator.
IsRequired bool Marks attribute as mandatory.
LinkEmployeeData bool Links attribute values to Employee entities.
LinkJobData bool Links attribute values to Job entities.
LinkCustomerData bool Links attribute values to Customer entities.
AddedBy string Username/ID of creator.
AddedDate DateTime Timestamp of creation.
ModifiedBy string Username/ID of last modifier.
ModifiedDate DateTime Timestamp of last modification.

UML Class Diagram

classDiagram
    class DocumentAttribute {
        +Guid Id
        +string AttributeName
        +AttributeType AttributeType
        +bool IsMultiValue
        +bool IsSafety
        +bool IsLegalDocument
        +bool IsIT
        +bool IsAccounting
        +bool IsBidding
        +bool IsHR
        +ImagingType ImagingType
        +string Values
        +string DocumentType
        +bool IsAvailable
        +bool IsDeleted
        +bool IsRequired
        +bool LinkEmployeeData
        +bool LinkJobData
        +bool LinkCustomerData
        +string AddedBy
        +DateTime AddedDate
        +string ModifiedBy
        +DateTime ModifiedDate
    }
    enum AttributeType {
        Date
        Text
        Character
        Boolean
        Number
        Currency
    }

Sample Code Blocks & Usage Examples

1. Creating a New DocumentAttribute

var safetyCheck = new DocumentAttribute
{
    Id               = Guid.NewGuid(),
    AttributeName    = "SafetyInspectionDate",
    AttributeType    = AttributeType.Date,
    IsMultiValue     = false,
    IsSafety         = true,
    DocumentType     = "InspectionReport",
    IsAvailable      = true,
    IsRequired       = true,
    AddedBy          = currentUser,
    AddedDate        = DateTime.UtcNow,
    ModifiedBy       = currentUser,
    ModifiedDate     = DateTime.UtcNow
};

dbContext.DocumentAttributes.Add(safetyCheck);
dbContext.SaveChanges();

2. Querying Attributes by Category

// Fetch all "Legal" attributes that are currently available
var legalAttributes = dbContext.DocumentAttributes
    .Where(a => a.IsLegalDocument && a.IsAvailable)
    .OrderBy(a => a.AttributeName)
    .ToList();

3. Defining Allowed Values (for dropdowns)

var statusAttr = new DocumentAttribute
{
    Id = Guid.NewGuid(),
    AttributeName = "JobStatus",
    AttributeType = AttributeType.Text,
    IsMultiValue = false,
    Values = "New|InProgress|Completed|OnHold",
    DocumentType = "JobSheet",
    IsAvailable = true,
    AddedBy = "system",
    AddedDate = DateTime.UtcNow,
    ModifiedBy = "system",
    ModifiedDate = DateTime.UtcNow
};

Conclusion

The DocumentAttribute class is a versatile entity for capturing dynamic metadata on documents within the Irby Imaging platform. By combining:

  • Flexible typing (AttributeType)
  • Categorization (Safety, Legal, etc.)
  • Linking to core domain entities (Employee, Job, Customer)
  • Audit tracking

you gain a robust, schema-driven solution to manage document properties and drive UI behaviors or validation logic.

:sparkles: Happy coding!