📑 Documentation: IrbyImaging.UI.Models.DocumentTypeView.cs
📋 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- UML Class Diagram
- View Models & Data Models
- Properties & Descriptions
- Sample Code Blocks & Usage Examples
- Dependencies & Third‑Party Integrations
- Conclusion & Best Practices
1. Overview & Purpose
🎯 IrbyImaging.UI.Models.DocumentTypeView.cs defines view models for the IrbyImaging UI layer. These classes encapsulate metadata about document types, their attributes, and categorization. They are typically used to:
- Transfer data from controllers to Razor views or APIs.
- Collect user input when creating or editing document types.
- Render lists of document types with dynamic filters/attributes.
2. Dependencies & Technologies
| Category | Details |
|---|---|
| Language | C# (.NET 6+) |
| Framework | ASP.NET Core MVC (UI layer) |
| Annotations | System.ComponentModel.DataAnnotations |
| ORM / Data Mapping | N/A (View Models only) |
| Utility Libraries | IrbyImaging.Utility |
| Domain Classes | IrbyImaging.DomainClasses (for ImagingType) |
3. Key Functional Areas
-
DocumentTypeView
Holds the master record for a document type: ID, name, description, availability flags, attribute lists, audit fields. -
DocumentCategories
Lightweight model for categorizing document types (e.g., “HR”, “Safety”). -
DocumentTypeViewDetail
Similar toDocumentTypeViewbut used in nested/detail views (e.g., child listings).
4. UML Class Diagram
classDiagram
class DocumentTypeView {
+Guid Id
+string Type
+string Description
+bool IsAvailable
+bool IsDeleted
+bool IsSafety
+bool IsLegal
+bool IsIT
+bool IsAccounting
+bool IsBidding
+bool IsHR
+ImagingType ImagingType
+List<string> AttributeList
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
+List<DocumentTypeViewDetail> DocList
+List<DocumentAttributeViewDetail> IndexList
+string Value
+string Category
}
class DocumentCategories {
+string Name
+string Id
+bool IsSelected
}
class DocumentTypeViewDetail {
+Guid Id
+string Type
+bool IsAvailable
+bool IsDeleted
+bool IsSafety
+bool IsLegal
+bool IsIT
+bool IsAccounting
+bool IsBidding
+ImagingType ImagingType
+List<string> AttributeList
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
+string Category
}
DocumentTypeView --> "0..*" DocumentTypeViewDetail : DocList
DocumentTypeView --> "0..*" DocumentAttributeViewDetail : IndexList
5. View Models & Data Models
5.1 DocumentTypeView 🏷️
public class DocumentTypeView
{
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 IsLegal { 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; }
public List<string> AttributeList { 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; }
public List<DocumentTypeViewDetail> DocList { get; set; }
public List<DocumentAttributeViewDetail> IndexList { get; set; }
public string Value { get; set; }
public string Category { get; set; }
}
Usage: Represents the master information about a single document type in the UI.
5.2 DocumentCategories 📂
public class DocumentCategories
{
public string Name { get; set; }
public string Id { get; set; }
public bool IsSelected { get; set; }
}
Usage: Populates dropdowns or multi‑select lists for categories (e.g., Safety, HR).
5.3 DocumentTypeViewDetail 📑
public class DocumentTypeViewDetail
{
public Guid Id { get; set; }
public string Type { get; set; }
public bool IsAvailable { get; set; }
public bool IsDeleted { get; set; }
public bool IsSafety { get; set; }
public bool IsLegal { get; set; }
public bool IsIT { get; set; }
public bool IsAccounting { get; set; }
public bool IsBidding { get; set; }
public ImagingType ImagingType { get; set; }
public List<string> AttributeList { 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; }
public string Category { get; set; }
}
Usage: Used to render child/detail entries under a master
DocumentTypeViewor in tabular “details” UI.
6. Properties & Descriptions
| Property | Type | Description |
|---|---|---|
| Id | Guid | Unique identifier for the document type. |
| Type | string | Name of the document type (e.g., “Invoice”, “Safety Report”). |
| Description | string | Detailed description or notes. |
| IsAvailable | bool | Flag to show/hide the type in UI. |
| IsDeleted | bool | Soft‑delete marker. |
| IsSafety / IsLegal… | bool | Category flags—for filtering/grouping in UI. |
| ImagingType | ImagingType (enum) | Underlying domain classification (e.g., PDF, JPEG). |
| AttributeList | List | Dynamic list of attribute names associated with this type. |
| AddedBy / ModifiedBy | string | Audit trail: user names. |
| AddedDate / ModifiedDate | DateTime | Audit trail timestamps. |
| DocList | List | Child/master details collection. |
| IndexList | List | Additional attributes for indexing/search. |
| Value | string | Generic holder for UI filters or dropdown values. |
| Category | string | Human‑readable category label. |
7. Sample Code Blocks & Usage Examples
7.1 Mapping Domain → ViewModel 🔄
// In your Controller or Service layer:
IEnumerable<DocumentType> domainList = _docTypeService.GetAll();
List<DocumentTypeView> viewModels = domainList.Select(d => new DocumentTypeView {
Id = d.Id,
Type = d.Type,
Description = d.Description,
IsAvailable = !d.IsDeleted,
IsSafety = d.Categories.Contains("Safety"),
IsLegal = d.Categories.Contains("Legal"),
ImagingType = d.ImagingType,
AttributeList= d.Attributes.Select(a => a.Name).ToList(),
AddedBy = d.CreatedBy,
AddedDate = d.CreatedDate,
ModifiedBy = d.UpdatedBy,
ModifiedDate = d.UpdatedDate,
Category = string.Join(", ", d.Categories)
}).ToList();
// Return to a Razor view
return View(viewModels);
7.2 Razor View Rendering 🖥️
@model IEnumerable<IrbyImaging.UI.Models.DocumentTypeView>
<table class="table">
<thead>
<tr>
<th>Type</th>
<th>Category</th>
<th>Attributes</th>
<th>Available</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach(var dt in Model) {
<tr>
<td>@dt.Type</td>
<td>@dt.Category</td>
<td>@string.Join(", ", dt.AttributeList)</td>
<td>
@if(dt.IsAvailable) {
<span class="badge bg-success">Yes</span>
} else {
<span class="badge bg-danger">No</span>
}
</td>
<td>
<a asp-action="Edit" asp-route-id="@dt.Id">✏️ Edit</a> |
<a asp-action="Delete" asp-route-id="@dt.Id">🗑️ Delete</a>
</td>
</tr>
}
</tbody>
</table>
8. Dependencies & Third‑Party Integrations
-
IrbyImaging.Utility
Provides shared utility methods (e.g., formatting, logging) used when manipulating these view models. -
IrbyImaging.DomainClasses
Defines theImagingTypeenum and domain entities that back this view.
No direct third‑party NuGet packages are referenced in this file.
9. Conclusion & Best Practices ✅
-
Separation of Concerns
These classes live in the UI project; they do not contain business logic or data‑access code. -
Validation & Annotations
Extend these view models with[Required],[StringLength], or custom validators as needed for robust input validation. -
Mapping
For large projects, consider using AutoMapper to streamline domain ↔ view‑model transformations. -
Extensibility
If you add new document categories, update the boolean flags and UI filters accordingly.
Thank you for reviewing the DocumentTypeView.cs documentation!
💡 Feel free to adapt the snippets and models to your specific requirements.