📄 Documentation: CreateType.cshtml
Welcome to the comprehensive documentation for the Create Document Type Razor View in the IrbyImaging application. This Markdown guide covers everything you need to understand, extend, and use the CreateType.cshtml file located in IrbyImaging/Views/LegalImaging/.
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model & Data Models
- Layout & Page Titles
- Form Structure & Key Functional Areas
- JavaScript & Assets
- Sample Usage & Code Snippets
- UML Diagram
- Conclusion
1. Overview & Purpose
File: IrbyImaging/Views/LegalImaging/CreateType.cshtml
Responsibility: Render a form for creating a new Document Type within the Document Imaging workflow.
Intended Use:
- Let legal/safety/IT users define a new document classification (
Type,Description). - Associate it with Document Categories and Index Types via Syncfusion EJ2 controls.
- Submit to the
CreateDocTypeaction in theLegalImagingcontroller.
2. Dependencies & Technologies
| Category | Technology / Library |
|---|---|
| View Engine | ASP.NET Core Razor Views |
| JavaScript UI | Syncfusion EJ2: ejs-dropdownlist, ejs-multiselect |
| CSS & Layout | Bootstrap 4+, Custom _LegalLayout.cshtml |
| Validation | ASP.NET Core Tag Helpers (asp-validation-for) |
| Utilities/JS | metisMenu, simplebar, waves |
⚙️ Syncfusion EJ2
The view leverages Syncfusion’s JavaScript components for rich dropdown and multiselect UX.
3. View Model & Data Models
// IrbyImaging.UI.Models.DocumentTypeView
public class DocumentTypeView
{
public int Id { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public string ImagingType { get; set; }
public bool IsLegal { get; set; }
public bool IsSafety { get; set; }
public bool IsIT { get; set; }
public List<int> Categories { get; set; }
public List<int> IndexTypes { get; set; }
}
- Purpose: Captures form inputs and hidden flags determining which branch (Legal, Safety, IT) this type belongs to.
- Binding:
@model IrbyImaging.UI.Models.DocumentTypeView
4. Layout & Page Titles
@{
ViewBag.Title = "Create Document Type";
ViewBag.pTitle = "Create Document Types";
ViewBag.pageTitle = "Create Document Types";
Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
- Layout:
_LegalLayout.cshtmlprovides navigation and legal-imaging-specific styling. - ViewBag Titles: Used in layout/header to display breadcrumbs and page header text.
5. Form Structure & Key Functional Areas
<h2>Create Document Type</h2>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="CreateDocType">
<!-- Hidden Fields -->
<!-- Type & Description Inputs -->
<!-- Categories Dropdown -->
<!-- Index Types MultiSelect -->
<!-- Action Buttons -->
</form>
</div>
</div>
5.1 Hidden Fields
@Html.HiddenFor(m => m.ImagingType)
@Html.HiddenFor(m => m.IsLegal)
@Html.HiddenFor(m => m.IsSafety)
@Html.HiddenFor(m => m.IsIT)
- Preserve routing/context flags across post-back.
5.2 Document Type Inputs
<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>
<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>
- Validation: ASP.NET Core’s unobtrusive validation via
asp-validation-for. - Binding: Two-way model binding with
asp-for.
5.3 Document Categories Dropdown
<div class="form-group row mb-2">
<label class="col-sm-2">Document Categories</label>
<div class="col-sm-12">
<div class="input-group">
<ejs-dropdownlist
id="Category"
width="900px"
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>
</div>
- DataSource:
@ViewBag.datashould be a list of{ Id, Type, Category }objects. - Grouping:
groupBy="Category"organizes options under category headings.
5.4 Index Types MultiSelect
<div class="form-group row mb-2">
<label class="col-sm-2">Index Types</label>
<div class="col-sm-12">
<div class="input-group">
<ejs-multiselect
id="indexType"
width="900px"
placeholder="Index types"
mode="CheckBox"
popupHeight="200px"
dataSource="@ViewBag.indexes">
<e-multiselect-fields
text="Type"
value="Id">
</e-multiselect-fields>
</ejs-multiselect>
</div>
</div>
</div>
- CheckBox Mode: Enables selecting multiple index types in one go.
- DataSource:
@ViewBag.indexeslist of{ Id, Type }.
5.5 Action Buttons
<div class="form-group">
<a asp-controller="LegalImaging"
asp-action="DocumentTypes"
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>
- Back Button: Returns user to document types listing.
- Submit Button: Posts to
CreateDocTypeaction.
6. JavaScript & Assets
<!-- Required JS Plugins -->
<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>
- Bootstrap: Modals, tooltips, form styling.
- metisMenu & simplebar: Sidebar navigation enhancements.
- waves: Ripple click effects.
7. Sample Usage & Code Snippets
7.1 Controller Action
public IActionResult CreateType(string imagingType, bool isLegal, bool isSafety, bool isIT)
{
var model = new DocumentTypeView {
ImagingType = imagingType,
IsLegal = isLegal,
IsSafety = isSafety,
IsIT = isIT
};
ViewBag.data = _categoryService.GetGroupedCategories();
ViewBag.indexes = _indexService.GetAllIndexTypes();
return View("CreateType", model);
}
[HttpPost]
public IActionResult CreateDocType(DocumentTypeView model, int Category, List<int> indexType)
{
if (!ModelState.IsValid)
return View("CreateType", model);
_docTypeService.Add(new DocumentTypeDto {
Type = model.Type,
Description = model.Description,
CategoryId = Category,
IndexTypeIds = indexType,
ImagingType = model.ImagingType
});
return RedirectToAction("DocumentTypes", new { imagingType = model.ImagingType });
}
7.2 ViewBag Data Example
// For DropDownList
ViewBag.data = new[]
{
new { Id = 1, Type = "Contract", Category = "Legal" },
new { Id = 2, Type = "Patent", Category = "Legal" },
new { Id = 3, Type = "SafetyReport", Category = "Safety" },
// ...
};
// For MultiSelect
ViewBag.indexes = new[]
{
new { Id = 10, Type = "Index A" },
new { Id = 11, Type = "Index B" },
// ...
};
8. UML Diagram
classDiagram
class DocumentTypeView {
+int Id
+string Type
+string Description
+string ImagingType
+bool IsLegal
+bool IsSafety
+bool IsIT
+List<int> Categories
+List<int> IndexTypes
}
class LegalImagingController {
+IActionResult CreateType(string, bool, bool, bool)
+IActionResult CreateDocType(DocumentTypeView, int, List<int>)
}
DocumentTypeView --> LegalImagingController : binds to
9. Conclusion
🎉 Key Takeaways
- CreateType.cshtml is a strongly-typed Razor view leveraging Syncfusion EJ2 controls for rich dropdown/multiselect experiences.
- Hidden flags in the model manage context (Legal/Safety/IT).
- Form posts to
CreateDocTypefor server-side validation and persistence. - With clear separation of ViewModel, Tag Helpers, and third‑party assets, this view is maintainable and extendable.
Feel free to adapt the dropdown height/width, styling classes, or integrate additional validation messages to suit your business rules. Happy coding! 🚀
End of documentation for
CreateType.cshtml