πŸ“š Documentation for DocumentCategory.cs

Assembly: IrbyImaging.DomainClasses
Namespace: IrbyImaging.DomainClasses
Author: kvamshi
Created: 06-22-2022
Last Modified: 06-22-2022


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. Data Model: DocumentCategory
  5. UML Class Diagram
  6. Usage Examples
  7. Helper Methods & Utilities
  8. Error Handling & Return Types
  9. API Endpoints Overview
  10. Third-party Integrations
  11. 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 the irby.DocumentCategory table 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) or bool/Result wrappers indicating success/failure.

🌐 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