π Documentation for DocumentCategory.cs
Assembly: IrbyImaging.DomainClasses
Namespace:IrbyImaging.DomainClasses
Author: kvamshi
Created: 06-22-2022
Last Modified: 06-22-2022
π Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- Data Model: DocumentCategory
- UML Class Diagram
- Usage Examples
- Helper Methods & Utilities
- Error Handling & Return Types
- API Endpoints Overview
- Third-party Integrations
- Conclusion
π Overview & Purpose
The DocumentCategory class is a domain model representing categorizations of documents within the Irby Imaging system. Each category has metadata such as a humanβreadable name, availability flags, and auditing fields (AddedBy, AddedDate, etc.).
Use this class to:
- Organize documents by type (e.g., Safety, Legal, HR, IT, Accounting, Bidding).
- Control availability and logical deletion.
- Track creation and modification for auditing purposes.
π Key Functional Areas
- Schema Mapping
[Table("DocumentCategory", Schema = "irby")]maps to theirby.DocumentCategorytable in the database. - Primary Key
[Key] public Guid Id { get; set; } - Categorization Flags
Boolean properties indicate category specializations (e.g.,IsSafety,IsLegalDocument,IsHR). - Auditing
AddedBy,AddedDate,ModifiedBy,ModifiedDate.
π Dependencies & Technologies
| Dependency | Purpose |
|---|---|
| System | Core types (e.g., Guid, DateTime) |
| System.Collections.Generic | Collection types (if extending model with lists) |
| System.ComponentModel.DataAnnotations | Data annotation attributes ([Key], [Display]) |
| System.ComponentModel.DataAnnotations.Schema | Schema mapping ([Table]) |
| Entity Framework Core (implied) | ORM for DB persistence |
π Data Model: DocumentCategory
4.1 Class Definition
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IrbyImaging.DomainClasses
{
/// <summary>
/// Represents a document category within the Irby imaging system.
/// </summary>
[Table("DocumentCategory", Schema = "irby")]
public class DocumentCategory
{
[Key]
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsAvailable { get; set; }
public bool IsDeleted { get; set; }
// Category-type 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; }
public ImagingType ImagingType { get; set; }
// Auditing 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; }
}
}
4.2 Properties Reference Table
| Property | Type | Description |
|---|---|---|
| Id | Guid |
Primary key. |
| Name | string |
Display name of the category. |
| Description | string |
Detailed description. |
| IsAvailable | bool |
Flag indicating if new documents can be assigned to this category. |
| IsDeleted | bool |
Soft-delete flag. |
| IsSafety | bool |
True if category relates to Safety documents. |
| IsLegalDocument | bool |
True if category relates to Legal documents. |
| IsIT | bool |
True if category relates to IT documents. |
| IsAccounting | bool |
True if category relates to Accounting documents. |
| IsBidding | bool |
True if category relates to Bidding documents. |
| IsHR | bool |
True if category relates to Human Resources documents. |
| ImagingType | enum |
Enum indicating specialized imaging workflow (see ImagingType enum). |
| AddedBy | string |
Username or ID of creator. |
| AddedDate | DateTime |
Timestamp when created. |
| ModifiedBy | string |
Username or ID of last modifier. |
| ModifiedDate | DateTime |
Timestamp when last updated. |
π UML Class Diagram
classDiagram
class DocumentCategory {
+Guid Id
+string Name
+string Description
+bool IsAvailable
+bool IsDeleted
+bool IsSafety
+bool IsLegalDocument
+bool IsIT
+bool IsAccounting
+bool IsBidding
+bool IsHR
+ImagingType ImagingType
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
}
π‘ Usage Examples
6.1 Creating & Persisting a Category
using (var context = new IrbyImagingDbContext())
{
var safetyCategory = new DocumentCategory
{
Id = Guid.NewGuid(),
Name = "Safety Manuals",
Description = "All safety-related documentation",
IsAvailable = true,
IsDeleted = false,
IsSafety = true,
IsLegalDocument = false,
IsIT = false,
IsAccounting = false,
IsBidding = false,
IsHR = false,
ImagingType = ImagingType.Standard,
AddedBy = "jdoe",
AddedDate = DateTime.UtcNow,
ModifiedBy = "jdoe",
ModifiedDate = DateTime.UtcNow
};
context.DocumentCategories.Add(safetyCategory);
context.SaveChanges();
}
6.2 Filtering by Document Type
// Retrieve all active Safety categories
var safetyCategories = context.DocumentCategories
.Where(dc => dc.IsAvailable && dc.IsSafety && !dc.IsDeleted)
.OrderBy(dc => dc.Name)
.ToList();
π§° Helper Methods & Utilities
Note: This class itself does not expose any helper methods. Helpers such as validation, mapping, or businessβlogic are expected to reside in service or utility layers outside this domain class.
β οΈ Error Handling & Return Types
- Entity Level: No direct error handling. Exceptions (e.g.,
DbUpdateException) bubble up to calling code. - Return Types:
- Repository/service methods should return either the entity (
DocumentCategory) orbool/Resultwrappers indicating success/failure.
- Repository/service methods should return either the entity (
π API Endpoints Overview
This domain class underpins potential RESTful APIs for managing categories:
- GET
/api/documentcategories- GET
/api/documentcategories/{id}- POST
/api/documentcategories- PUT
/api/documentcategories/{id}- DELETE
/api/documentcategories/{id}
(Endpoints to be implemented in Web API layer.)
π Third-party Integrations
- Entity Framework Core
- Uses EF Core conventions and data annotations for ORM mapping.
- Swagger / OpenAPI (optional)
- If exposing through Web API, add XML comments to generate API documentation automatically.
π Conclusion
The DocumentCategory class is a foundational domain model in the Irby Imaging system, enabling robust categorization, availability control, and auditing of documents. By leveraging EF Core attributes, it seamlessly integrates into a relational database and forms the backbone of document-management workflows (e.g., Safety reviews, Legal approvals, HR record-keeping).
Tip: Extend this model with navigation properties or validation logic in service layers as your domain grows! π
End of documentation for DocumentCategory.cs