📄 Search.cshtml Documentation
Welcome to the comprehensive documentation for IrbyImaging/Views/AccountingImaging/Search.cshtml. This view powers the “Search Uploaded Document” page in the Accounting Imaging module. Below you will find a detailed breakdown of its structure, technologies, data flow, and usage examples.
📑 Table of Contents
- 🔎 Overview & Purpose
- 🛠 Dependencies & Technologies
- 🗂 View Model & Data Models
- ⚙️ Page Structure & Layout
- 🎯 Key Functional Areas
- 📊 Attribute‑to‑Control Mapping Table
- 📈 UML Diagrams
- 📝 Usage Example
- ✅ Conclusion
🔎 Overview & Purpose
Purpose
This Razor view renders a two‑step search interface:
- Select Document Type and click Get Indexes → retrieves indexing fields from the server.
- Enter Index Values and click Search Document → displays matching documents in a dynamic, paginated table.
It supports:
- Dynamic form generation based on IndexList.
- Linking to Employee, Job, Customer & State data.
- Preview, Detail, Edit, Delete, and OCR view actions.
🛠 Dependencies & Technologies
| Category | Libraries / Frameworks |
|---|---|
| ASP.NET Core MVC | Razor Views, Tag Helpers (asp-for, asp-items) |
| JavaScript Widgets | Syncfusion EJ2 (commented-out snippets) |
| jQuery | v3.5.1 |
| CSS Frameworks | Bootstrap Datepicker, Dropzone.css |
| Select2 | v4.1.0‑rc.0 |
| DataTables | v1.10.25 + Buttons v1.7.1 |
| JSON Serialization | Newtonsoft.Json |
🗂 View Model & Data Models
Primary Model
@model IrbyImaging.Models.DocumentImaging
| Property | Type | Description |
|---|---|---|
| DocumentImageId | Guid / int | Unique identifier for the document image |
| FilePath | string | Server path to the uploaded file |
| BatchIds | IEnumerable | IDs of batches to search within |
| DocumentTypes | IEnumerable | Drop‑down options for document types |
| DocumentType | string | Selected document type |
| IndexList | List | Metadata for each searchable/indexable attribute |
| EmployeeData | IEnumerable | Drop‑down items for Employee lookup |
| JobData | IEnumerable | Drop‑down items for Job lookup |
| CustomerData | IEnumerable | Drop‑down items for Customer lookup |
| StateData | IEnumerable | Drop‑down items for State lookup |
| ImagingList | List | Search results (for Results Table) |
| … | … | Additional flags (IsAccounting, IsLegalDocument, etc.) |
IndexModel (simplified)
public class IndexModel {
public int Id { get; set; }
public string AttributeName { get; set; }
public AttributeType AttributeType { get; set; }
public bool IsMultiValue { get; set; }
public bool LinkEmployeeData { get; set; }
public bool LinkJobData { get; set; }
public bool LinkCustomerData { get; set; }
public bool IsRequired { get; set; }
public IEnumerable<SelectListItem> MultiValueTypes { get; set; }
public string IndexValue { get; set; }
}
⚙️ Page Structure & Layout
- Directives & Usings
@model IrbyImaging.Models.DocumentImaging @using Syncfusion.JavaScript @using Newtonsoft.Json - ViewData Title
@{ ViewData["Title"] = "Search Uploaded Document"; } - Batch IDs Initialization
@section styles– include CSS for datepicker & dropzone- Get Indexes Form – select document type
- Search Documents Form – dynamic index fields
- Results Table – display
Model.ImagingList @section Scripts– jQuery, Select2 activation
🎯 Key Functional Areas
5.1 Batch ID Initialization
var lists = Model.BatchIds;
string guidList = "";
foreach (var list in lists) {
guidList += list + ",";
}
- Purpose: Build a comma‑separated string of batch GUIDs for hidden field posting.
5.2 Styles & Scripts Sections
@section styles {
<link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="~/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />
}
...
@section Scripts {
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/select2/dist/css/select2.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/select2/dist/js/select2.min.js"></script>
<script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
</script>
}
- Select2: enhances
<select>elements with search/filter UI.
5.3 “Get Indexes” Form
<form asp-action="Search" method="post" class="form-horizontal" id="validation-form">
@Html.HiddenFor(m => m.DocumentImageId)
@* … other hidden fields … *@
@Html.AntiForgeryToken()
<h4>Select Document Type</h4>
<select asp-for="DocumentType"
asp-items="@Model.DocumentTypes"
class="form-control col-sm-6">
<option disabled selected>Select Document Type</option>
</select>
<button type="submit" class="btn btn-primary">Get Indexes</button>
</form>
- Posts to:
AccountingImagingController.Search(DocumentImaging model) - Result: populates
Model.IndexList
5.4 “Search Documents” Form
<form asp-action="List" method="post" class="form-horizontal">
@* Hidden fields, AntiForgeryToken, ValidationSummary … *@
@if (Model.IndexList.Any()) {
<h4>Search Documents</h4>
<div data-repeater-list="outer-group">
<div data-repeater-item>
<!-- Loop through Model.IndexList and render controls -->
</div>
</div>
<button type="submit" class="btn btn-primary">Search Document</button>
}
</form>
- Dynamic controls based on attribute metadata (see Mapping Table).
5.5 Results Table
@if (Model.ImagingList != null && Model.ImagingList.Any()) {
<table id="datatable-buttons" class="table table-striped ...">
<thead>
<tr>
<th>Document Type</th>
@foreach(var idx in Model.ImagingList.First().IndexList)
{ <th>@idx.AttributeName</th> }
<th>Details</th><th>Preview</th><th>View</th><th>Edit</th><th>Delete</th>
</tr>
</thead>
<tbody>
@foreach (var doc in Model.ImagingList) {
<tr>
<td>@doc.DocumentType</td>
@foreach(var idx in doc.IndexList)
{ <td>@idx.IndexValue</td> }
<td>
<a href="javascript:void(0);" class="anchorDetail" data-id="@doc.DocumentImageId">Details</a>
<!-- Modal markup -->
</td>
<!-- Preview, ActionLinks -->
</tr>
}
</tbody>
</table>
}
- DataTables styling + Buttons plugin for export features.
5.6 JavaScript Interactivity
- Select2:
.js-example-basic-singleselects. - Modal Popups:
.anchorDetail&.anchorDetail1trigger AJAX content load into#myModalContent.
📊 Attribute‑to‑Control Mapping Table
| AttributeType | Conditions | Rendered Control |
|---|---|---|
| Text | !IsMultiValue, no Links, not “State” | <textarea> |
| Character | !IsMultiValue, no Links, not “State” | <textarea> |
| Date | AttributeType == Date |
<input type="date"> |
| Number | AttributeType == Number |
<input type="number" step="0.01"> |
| Currency | AttributeType == Currency |
$ <input type="number" ...> |
| Boolean | AttributeType == Boolean |
<select> with Yes / No |
| MultiValue | IsMultiValue == true |
<select asp-items="@MultiValueTypes"> |
| LinkEmployeeData | LinkEmployeeData == true |
<select asp-items="@Model.EmployeeData"> |
| LinkJobData | LinkJobData == true |
<select asp-items="@Model.JobData"> |
| LinkCustomerData | LinkCustomerData == true |
<select asp-items="@Model.CustomerData"> |
| “State” in name | AttributeName.Contains("State") |
<select asp-items="@Model.StateData"> |
| Fallback | Any other | <textarea> |
📈 UML Diagrams
1. Class Diagram (simplified)
+---------------------+
| DocumentImaging |
+---------------------+
| -DocumentImageId |
| -FilePath |
| -BatchIds |
| -DocumentTypes |
| -DocumentType |
| -IndexList |<---+
| -EmployeeData | |
| -JobData | |
| -CustomerData | |
| -StateData | |
| -ImagingList | |
+---------------------+ |
|
+---------------------+ |
| IndexModel |----+
+---------------------+
| -Id |
| -AttributeName |
| -AttributeType |
| -IsMultiValue |
| -LinkEmployeeData |
| -LinkJobData |
| -LinkCustomerData |
| -MultiValueTypes |
| -IndexValue |
+---------------------+
2. Sequence Diagram (high‑level)
User
|
|-- GET /AccountingImaging/Search --> RazorView (empty IndexList)
|
|-- Select Document Type & POST /Search --> Controller.Search(...)
| populates IndexList
|
|<------------------- Render RazorView with dynamic fields
|
|-- User fills indexes & POST /List ----> Controller.List(...)
| returns ImagingList
|
|<--- Render RazorView with Results Table
📝 Usage Example
- Navigate to
/AccountingImaging/Search. - Select a Document Type (e.g., “Invoice”).
- Click Get Indexes → Fields such as “Invoice Number”, “Date”, “Amount” appear.
- Fill in the values (e.g., INV‑123, 2023‑06‑01, $150.00 ).
- Click Search Document → results table loads matching records.
- Actions:
- Details/Preview: Opens modal via AJAX
- View OCR: New window to see OCR text
- Edit/Delete: Open edit form or confirm deletion
✅ Conclusion
Search.cshtml is a dynamic, two‑step Razor view that:
- Adapts form fields based on document metadata.
- Integrates select2, DataTables, and modals for a rich UI.
- Provides a streamlined workflow to index, search, and manage uploaded accounting documents.
Feel free to explore the related AccountingImagingController actions (Search, List, ViewOCR, Edit, DeleteUploadedDocument) and the DocumentImaging model for deeper integration details. Enjoy building powerful document imaging features! 🚀