📝 Edit Document Category View Documentation
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model & Data Model
- File Structure & Razor Directives
- Form Layout & Key Functional Areas
- API Endpoints Overview
- Third‑Party Integrations
- Error Handling & Validation
- Sample Code Blocks & Usage Examples
- UML Diagrams
- Conclusion
1. Overview & Purpose
File: IrbyImaging/Views/HRImaging/EditCategory.cshtml
This Razor view renders an “Edit Document Category” form in the HR Imaging area of the Irby Imaging web application.
It allows users to:
- View and edit the Description, Availability, and Deletion flags of an existing document category.
- Launch the update process by submitting the form to the backend.
- Navigate back to the categories list.
🎯 Primary Goals
- Provide a user-friendly UI for updating metadata of document categories.
- Maintain data integrity by making the Name read‑only (non‑editable) once created.
2. Dependencies & Technologies
| Dependency/Library | Purpose |
|---|---|
| ASP.NET Core MVC Razor | Server‑side view engine |
Syncfusion.JavaScript & EJ2 (@using) |
UI widgets & client‑side utilities |
Bootstrap 5 (bootstrap.bundle.min.js) |
Responsive styling & components (buttons, forms) |
MetisMenu (metisMenu.min.js) |
Sidebar menu plugin |
SimpleBar (simplebar.min.js) |
Custom scrollbar |
Waves (waves.min.js) |
Ripple effects for buttons |
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2
3. View Model & Data Model
This view is strongly‑typed to the DocumentCategoryView model, defined in:
namespace IrbyImaging.UI.Models
{
public class DocumentCategoryView
{
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; }
}
}
Key Properties
| Property | Type | Description |
|---|---|---|
Id |
Guid | Unique identifier of the document category |
Name |
string | Human‑readable name (read‑only in edit mode) |
Description |
string | Detailed description or notes |
IsAvailable |
bool | Toggle to mark category as available/unavailable |
IsDeleted |
bool | Soft‑delete flag |
4. File Structure & Razor Directives
@model IrbyImaging.UI.Models.DocumentCategoryView
@{
ViewBag.Title = "Edit Document Category";
ViewBag.pTitle = "Edit Document Category";
ViewBag.pageTitle = "Edit Document Category";
Layout = "~/Views/Shared/_Layout.cshtml";
}
- @model: Declares the view‑model type.
- ViewBag: Supplies page titles and can be leveraged in the shared layout.
- Layout: References the master layout for consistent header, footer, and nav.
5. Form Layout & Key Functional Areas
<h2>Update Document Type</h2>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="EditDocCategory">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<!-- Hidden Id Field -->
<input type="hidden" asp-for="Id" />
<!-- Name (Read‑only) -->
<div class="form-group">
<label asp-for="Name" class="control-label"></label>
<input asp-for="Name" class="form-control" required readonly />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<!-- Description -->
<div class="form-group">
<label asp-for="Description" class="control-label"></label>
<input asp-for="Description" class="form-control" />
<span asp-validation-for="Description" class="text-danger"></span>
</div>
<!-- IsAvailable -->
<div class="form-group">
<label asp-for="IsAvailable" class="control-label"></label>
<input asp-for="IsAvailable" type="checkbox" />
<span asp-validation-for="IsAvailable" class="text-danger"></span>
</div>
<!-- IsDeleted -->
<div class="form-group">
<label asp-for="IsDeleted" class="control-label"></label>
<input asp-for="IsDeleted" type="checkbox" />
<span asp-validation-for="IsDeleted" class="text-danger"></span>
</div>
<!-- Action Buttons -->
<div class="form-group">
<a asp-action="DocumentCategories" asp-controller="HRImaging"
class="btn btn-danger irby-red">🔙 Back to List</a>
<input type="submit" value="Update" class="btn btn-success irby-green" />
</div>
</form>
</div>
</div>
Key Functional Areas
- Validation Summary
- Displays model‑level validation errors.
- Hidden Field (
Id)- Ensures the server knows which record is being updated.
- Read‑only Name
- Prevents renaming an existing category, preserving referential integrity.
- Editable Fields
- Description, IsAvailable, IsDeleted.
- Action Buttons
- Back to List: Navigates to the categories overview.
- Update: Posts form data to
EditDocCategory.
6. API Endpoints Overview
| Action Method | Controller | Route | HTTP Verb | Purpose |
|---|---|---|---|---|
EditDocCategory |
HRImaging |
/HRImaging/EditDocCategory |
POST | Accepts edited model, validates, persists changes, then redirects. |
DocumentCategories |
HRImaging |
/HRImaging/DocumentCategories |
GET | Returns the list view of all document categories. |
7. Third‑Party Integrations
-
Syncfusion EJ2
While no explicit Syncfusion UI widget is used here, the@usingdirectives prepare the view to incorporate rich client‑side controls (e.g., dropdowns, grids) if needed in the future. -
Bootstrap 5
Provides responsive form layouts, button styling, and grid system (row,col-md-4). -
MetisMenu / SimpleBar / Waves
Enhance the master layout for side‑navigation and minor UI effects.
8. Error Handling & Validation
-
Client‑side
- HTML5 attributes (
required) for quick validations. <span asp-validation-for="...">for per‑field error display.
- HTML5 attributes (
-
Server‑side
[Required],[StringLength]etc. onDocumentCategoryViewproperties enforce data rules.ModelState.IsValidin the controller action handles invalid submissions and re‑renders the view with error messages.
9. Sample Code Blocks & Usage Examples
9.1 Controller Action (C#)
[HttpGet]
public IActionResult EditDocCategory(Guid id)
{
var model = _service.GetCategoryViewById(id);
if (model == null) return NotFound();
return View(model); // Renders EditCategory.cshtml
}
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult EditDocCategory(DocumentCategoryView viewModel)
{
if (!ModelState.IsValid)
return View(viewModel);
_service.UpdateCategory(viewModel);
return RedirectToAction("DocumentCategories");
}
9.2 Routing & Navigation
<!-- Link from the list page -->
<a asp-controller="HRImaging"
asp-action="EditDocCategory"
asp-route-id="@category.Id">Edit</a>
9.3 Styling Example (Custom CSS)
.irby-red { background-color: #d9534f; color: white; }
.irby-green { background-color: #5cb85c; color: white; }
10. UML Diagrams
10.1 Class Diagram (DocumentCategoryView)
@startuml
class DocumentCategoryView {
+Guid Id
+string Name
+string Description
+bool IsAvailable
+bool IsDeleted
}
@enduml
10.2 Sequence Diagram (Edit Flow)
@startuml
actor User
participant "EditCategory.cshtml" as View
participant HRImagingController
participant ServiceLayer
participant Database
User -> View: Clicks “Update”
View -> HRImagingController: POST /EditDocCategory(ViewModel)
HRImagingController -> ServiceLayer: UpdateCategory(ViewModel)
ServiceLayer -> Database: SQL UPDATE DocumentCategories
Database --> ServiceLayer: Success
ServiceLayer --> HRImagingController: Updated model
HRImagingController -> User: Redirect to DocumentCategories
@enduml
11. Conclusion
This Edit Document Category view is a focused UI component for modifying the non‑key attributes of a document category. Leveraging ASP.NET Core Razor, built‑in validation, and third‑party plugins, it provides a secure and responsive experience. By following the patterns shown—strongly‑typed view models, client & server validation, and clear routing—you can extend or reuse this approach for other CRUD operations within the Irby Imaging solution. 🚀
Feel free to customize the styling, integrate advanced Syncfusion controls, or extend validation logic to suit evolving business requirements!