📄 Documentation: CreateType.cshtml
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- ViewModel & DataModels
- Page Layout & Razor Structure
- Key Functional Areas
- 5.1. Form & Tag Helpers
- 5.2. Syncfusion DropDownList for Categories
- 5.3. Syncfusion MultiSelect for Index Types
- 5.4. Hidden Fields & Routing
- 5.5. Validation & Error Handling
- Third-Party Integrations
- Scripts & Client-Side Libraries
- Data Flow & API Endpoints
- UML Diagram
- Usage Examples
- Conclusion
1. Overview & Purpose 🚀
The CreateType.cshtml Razor view is part of the AccountingImaging area in the IrbyImaging application.
It renders a “Create Document Type” form that enables users to define new document types for the imaging module, including:
- Type (name of the document type)
- Description (details about the document)
- Document Categories (grouped via drop‑down)
- Index Types (selectable via multi‑select with checkboxes)
Once submitted, the form posts to the CreateDocType action in the AccountingImagingController, allowing backend logic to persist the new type.
2. Dependencies & Technologies 🔧
| Category | Technology / Library |
|---|---|
| Web Framework | ASP.NET Core MVC (Razor Pages) |
| UI Controls | Syncfusion EJ2 JavaScript Components |
| Styling & Layout | Bootstrap 5 |
| Menu & Sidebar | metisMenu, simplebar, node-waves |
| Client-Side Validation | jQuery Unobtrusive (built‑in ASP.NET) |
| Server-Side Tag Helpers | asp-for, asp-action, asp-controller, asp-route-* |
3. ViewModel & DataModels 🏗️
DocumentTypeView (in IrbyImaging.UI.Models) is the strongly-typed model for this view:
public class DocumentTypeView
{
public string Type { get; set; } // Name of the document type
public string Description { get; set; } // Description/details
public string ImagingType { get; set; } // e.g., "Accounting"
public bool IsLegal { get; set; }
public bool IsSafety { get; set; }
public bool IsIT { get; set; }
public bool IsAccounting { get; set; }
public bool IsBidding { get; set; }
// ... potentially other metadata or validation attributes
}
- ViewBag.Data Sources
ViewBag.data: list of document categoriesViewBag.indexes: list of index types
4. Page Layout & Razor Structure 🎨
@model IrbyImaging.UI.Models.DocumentTypeView
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2
@{
ViewBag.Title = "Create Document Type";
ViewBag.pTitle = "Create Document Types";
ViewBag.pageTitle = "Create Document Types";
}
<h2>Create Document Type</h2>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="CreateDocType">
@* Hidden metadata fields *@
@Html.HiddenFor(m => m.ImagingType)
@Html.HiddenFor(m => m.IsLegal)
@Html.HiddenFor(m => m.IsSafety)
@Html.HiddenFor(m => m.IsIT)
@Html.HiddenFor(m => m.IsAccounting)
@Html.HiddenFor(m => m.IsBidding)
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
@* Document Type Name *@
<div class="form-group">
<label asp-for="Type" class="control-label"></label>
<input asp-for="Type" class="form-control" />
<span asp-validation-for="Type" 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>
@* Document Categories DropDownList *@
<div class="form-group row mb-2">
<label class="col-sm-2">Document Categories</label>
<div class="col-sm-12">
<ejs-dropdownlist
width="900px"
id="Category"
placeholder="Select document category"
popupHeight="200px"
dataSource="@ViewBag.data">
<e-dropdownlist-fields
groupBy="Category"
text="Type"
value="Id">
</e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
</div>
@* Index Types MultiSelect *@
<div class="form-group row mb-2">
<label class="col-sm-2">Index Types</label>
<div class="col-sm-12">
<ejs-multiselect
width="900px"
id="indexType"
placeholder="Index types"
mode="CheckBox"
popupHeight="200px"
dataSource="@ViewBag.indexes">
<e-multiselect-fields text="Type" value="Id"></e-multiselect-fields>
</ejs-multiselect>
</div>
</div>
@* Actions *@
<div class="form-group">
<a asp-action="DocumentTypes"
asp-controller="LegalImaging"
asp-route-imagingType="@ViewBag.category"
class="btn btn-danger irby-red">
Back to List
</a>
<input type="submit" value="Create" class="btn btn-success irby-green" />
</div>
</form>
</div>
</div>
5. Key Functional Areas 🔍
5.1. Form & Tag Helpers
<form asp-action="CreateDocType">
Binds toCreateDocType(DocumentTypeView model)in the controller.asp-forbinds inputs to Model properties.asp-validation-forandasp-validation-summarydisplay server-side validation errors.
5.2. Syncfusion DropDownList for Categories
- Grouping by
Categoryfield. - Placeholder: “Select document category”.
- DataSource: passed from controller to
ViewBag.data.
5.3. Syncfusion MultiSelect for Index Types
- Mode:
CheckBoxallows multi-select with checkboxes. - DataSource: passed via
ViewBag.indexes. - Fields:
<e-multiselect-fields text="Type" value="Id" />.
5.4. Hidden Fields & Routing
- Hidden inputs carry ImagingType and boolean flags (
IsLegal,IsIT, etc.) to preserve context. - Back to List button uses
asp-route-imagingTypeto maintain filter in the listing view.
5.5. Validation & Error Handling
- Server-side validations defined in
DocumentTypeView(e.g.,[Required]onType). - Validation messages pop up inline next to inputs.
6. Third-Party Integrations 🌐
- Syncfusion EJ2
- Elegant, high-performance UI components.
<ejs-dropdownlist>and<ejs-multiselect>for rich client-side interactivity.
- Bootstrap for responsive grid & form styling.
- MetisMenu, Simplebar, Node-Waves for UI navigation & effects.
7. Scripts & Client-Side Libraries 📜
<script src="~/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="~/libs/metismenu/metisMenu.min.js"></script>
<script src="~/libs/simplebar/simplebar.min.js"></script>
<script src="~/libs/node-waves/waves.min.js"></script>
- Ensure these are registered after the form to power menus, scrolling, and ripple effects.
8. Data Flow & API Endpoints 🔄
GET /AccountingImaging/CreateType- Initializes
DocumentTypeViewwith default flags. - Populates
ViewBag.data&ViewBag.indexes.
- Initializes
POST /AccountingImaging/CreateDocType- Accepts
DocumentTypeViewpayload. - Validates & persists new document type via service layer.
- Redirects back to listing or re‑renders form with errors.
- Accepts
9. UML Diagram 🏷️
classDiagram
class DocumentTypeView {
+ string Type
+ string Description
+ string ImagingType
+ bool IsLegal
+ bool IsSafety
+ bool IsIT
+ bool IsAccounting
+ bool IsBidding
}
class AccountingImagingController {
+ IActionResult CreateType()
+ IActionResult CreateDocType(DocumentTypeView model)
+ IActionResult DocumentTypes(string imagingType)
}
DocumentTypeView <.. AccountingImagingController : uses
AccountingImagingController "1" --> "1" CreateType
AccountingImagingController "1" --> "1" CreateDocType
10. Usage Examples 💡
10.1. Navigating to the Form
GET https://yourapp/AccountingImaging/CreateType
- Renders empty form.
ViewBag.dataandViewBag.indexesloaded from database/services.
10.2. Submitting a New Type
POST https://yourapp/AccountingImaging/CreateDocType
Content-Type: application/x-www-form-urlencoded
Type=Invoice&Description=Customer%20Invoices&Category=2&IndexType=1&IndexType=3&IsAccounting=true
- On success, redirect to list:
/AccountingImaging/DocumentTypes?imagingType=Accounting. - On validation error, form re-renders with error messages.
11. Conclusion ✅
The CreateType.cshtml page provides a user-friendly, rich UI for defining new document types within the Accounting Imaging module. By leveraging Syncfusion EJ2 components and ASP.NET Core Tag Helpers, the form offers:
- Intuitive dropdown grouping for document categories
- Checkbox‑enabled multi-select for index types
- Seamless server-side validation
This ensures consistency, reusability, and a polished experience for administrators managing document taxonomy in the IrbyImaging platform.