📄 IrbyImaging.DomainClasses/DocumentType.cs Documentation
Welcome to the comprehensive documentation for the DocumentType domain class in the IrbyImaging.DomainClasses assembly. This document will walk you through the purpose, structure, usage, and design of the DocumentType class, complete with code snippets, a UML diagram, and usage examples.
🗂 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- Data Model & Schema Mapping
- Properties Reference Table
- UML Class Diagram
- Sample Code Block
- Usage Examples
- Conclusion
1. 🎯 Overview & Purpose
The DocumentType class is a domain entity that represents different categories of documents within the Irby Imaging system. It is designed to:
- Persist document type metadata to a relational database (using Entity Framework Core).
- Classify documents by various business-relevant flags (e.g., Safety, Legal, Accounting).
- Provide auditing information (who created/modified and when).
In short, DocumentType is the backbone for any functionality that needs to know “What kind of document is this?” and “Which departments or workflows does it pertain to?”
2. 🔧 Dependencies & Technologies
- .NET 5+ / .NET Core
- Entity Framework Core (via
System.ComponentModel.DataAnnotations&System.ComponentModel.DataAnnotations.Schema) - System collections (
Guid,DateTime,String,Boolean)
No third‑party integrations beyond EF Core are required for this class.
3. 🗝 Key Functional Areas
- Schema Mapping
- Maps the class to the
irby.DocumentTypetable in the database via[Table]and[Key]attributes.
- Maps the class to the
- Classification Flags
- Boolean properties to indicate whether the document type is used by Safety, Accounting, Legal, HR, IT, or Bidding teams.
- Auditing
- Tracks creation (
AddedBy,AddedDate) and modification (ModifiedBy,ModifiedDate).
- Tracks creation (
- General Metadata
- Stores
Type,Description,IsAvailable,IsDeleted, andDocumentCategory.
- Stores
4. 💾 Data Model & Schema Mapping
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IrbyImaging.DomainClasses
{
/// <summary>
/// Class DocumentType.
/// Represents a type/category of document within the Irby Imaging system.
/// </summary>
[Table("DocumentType", Schema = "irby")]
public class DocumentType
{
[Key]
public Guid Id { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public bool IsAvailable { get; set; }
public bool IsDeleted { get; set; }
public bool IsSafety { get; set; }
public bool IsAccounting { get; set; }
public bool IsBidding { get; set; }
public bool IsLegalDocument { get; set; }
public bool IsIT { get; set; }
public bool IsHR { get; set; }
public ImagingType ImagingType { get; set; }
public string DocumentCategory { get; set; }
[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; }
}
}
5. 📋 Properties Reference Table
| Property | Type | Database Column | Description |
|---|---|---|---|
| Id | Guid |
Id (PK) |
Unique identifier for the document type. |
| Type | string |
Type |
Short name of the document type (e.g., “Policy”, “Invoice”). |
| Description | string |
Description |
Detailed description or notes. |
| IsAvailable | bool |
IsAvailable |
Indicates if this type can currently be used. |
| IsDeleted | bool |
IsDeleted |
Soft-delete flag. |
| IsSafety | bool |
IsSafety |
Belongs to the Safety department. |
| IsAccounting | bool |
IsAccounting |
Belongs to the Accounting department. |
| IsBidding | bool |
IsBidding |
Pertains to bidding processes. |
| IsLegalDocument | bool |
IsLegalDocument |
Legal-related documentation. |
| IsIT | bool |
IsIT |
IT department documents. |
| IsHR | bool |
IsHR |
Human Resources documents. |
| ImagingType | ImagingType |
ImagingType |
Enum indicating the imaging workflow type. |
| DocumentCategory | string |
DocumentCategory |
Category grouping (e.g., “Technical”, “Financial”). |
| AddedBy | string |
AddedBy |
Username or service that created this record. |
| AddedDate | DateTime |
AddedDate |
UTC timestamp of creation. |
| ModifiedBy | string |
ModifiedBy |
Username or service that last modified this record. |
| ModifiedDate | DateTime |
ModifiedDate |
UTC timestamp of last modification. |
6. 🧩 UML Class Diagram
@startuml
package irby {
class DocumentType {
+ Guid Id
+ string Type
+ string Description
+ bool IsAvailable
+ bool IsDeleted
+ bool IsSafety
+ bool IsAccounting
+ bool IsBidding
+ bool IsLegalDocument
+ bool IsIT
+ bool IsHR
+ ImagingType ImagingType
+ string DocumentCategory
+ string AddedBy
+ DateTime AddedDate
+ string ModifiedBy
+ DateTime ModifiedDate
}
}
@enduml
Embed this UML in your docs or Visio to visualize the entity.
7. 💻 Sample Code Block
Below is how you might configure and add a new DocumentType in your EF Core DbContext:
using (var context = new IrbyImagingDbContext())
{
var docType = new DocumentType
{
Id = Guid.NewGuid(),
Type = "Safety Manual",
Description = "Standard operating procedures for on-site safety.",
IsAvailable = true,
IsSafety = true,
ImagingType = ImagingType.PDF,
DocumentCategory = "Compliance",
AddedBy = "admin",
AddedDate = DateTime.UtcNow
};
context.DocumentTypes.Add(docType);
context.SaveChanges();
}
8. 🚀 Usage Examples
- Filtering by Department
var safetyDocs = context.DocumentTypes .Where(dt => dt.IsSafety && !dt.IsDeleted); - Soft-Deleting a Document Type
var dt = context.DocumentTypes.Find(someGuid); dt.IsDeleted = true; dt.ModifiedBy = currentUser; dt.ModifiedDate = DateTime.UtcNow; context.SaveChanges(); - Loading by Category
var complianceTypes = context.DocumentTypes .Where(x => x.DocumentCategory == "Compliance");
9. ✅ Conclusion
The DocumentType class is a central data model for categorizing and managing document types in the Irby Imaging ecosystem. By leveraging EF Core’s data annotations, it provides:
- Clear schema mapping to the
irby.DocumentTypetable - Rich classification flags for multiple departments
- Built‑in auditing of creation and modification events
Use this entity as the foundation for any feature that needs to organize, query, or enforce business rules around document types. Enjoy building with confidence! 🎉
End of Document