đ SearchResults.cshtml Documentation
Welcome to the comprehensive documentation for the SearchResults.cshtml Razor view in the IrbyImaging application. This document covers every aspect of the viewâfrom its purpose and data models to styling, JavaScript integrations, and usage examples.
đ Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Models & Data Models
- Key Functional Areas
- Helper Methods & Utilities
- API Endpoints Overview
- Third-Party Integrations
- Sample Code Blocks
- Usage Example
- UML Diagrams
- Conclusion
1. Overview & Purpose
SearchResults.cshtml is the Razor View responsible for displaying the results of a document search in the Accounting Imaging module.
- It renders a search form (with hidden fields and anti-forgery tokens)
- It loops through a list of scanned documents (
Model.ImagingList) - It presents them in an interactive DataTable with options to View, Edit, or Delete each document
- It highlights rows based on expiration dates (e.g., expired, expiring soon)
đ Intended Use
- User enters search criteria (handled by a separate view/controller).
- POST to
AccountingImagingController.Searchreturns this view. - JavaScript enhances the table (sorting, exporting, row styling).
2. Dependencies & Technologies
| Category | Libraries & Frameworks |
|---|---|
| .NET / ASP.NET | Razor Pages (.cshtml), @model IrbyImaging.Models.DocumentImaging, HTML Helpers (Html.HiddenFor, ActionLink) |
| CSS | Bootstrap 4, DataTables (Bootstrap 4 styling), Responsive DataTables, Datepicker |
| JavaScript | jQuery, DataTables & Buttons Extensions, jsZip, pdfMake, ApexCharts, Google Charts, spin.js |
| Syncfusion | Syncfusion.JavaScript, Syncfusion.EJ2 (referenced but not directly used in markup) |
3. View Models & Data Models
namespace IrbyImaging.Models
{
public class DocumentImaging
{
public bool Preview { get; set; }
public int DocumentImageId { get; set; }
public List<ImagingItem> ImagingList { get; set; }
}
public class ImagingItem
{
public int DocumentImageId { get; set; }
public string DocumentType { get; set; }
public string FileName { get; set; }
public List<IndexItem> IndexList { get; set; }
}
public class IndexItem
{
public string AttributeName { get; set; }
public string IndexValue { get; set; }
}
}
- DocumentImaging
- Topâlevel view model
- Carries the list of scanned documents plus flags like
Preview
- ImagingItem
- Represents a single document with its indices
- IndexItem
- Keyâvalue pair for dynamic âIndex Searchedâ columns
4. Key Functional Areas
4.1 Search Form & Hidden Fields
<form asp-action="Search" method="post" class="searchForm" id="validation-form">
@Html.HiddenFor(m => m.Preview)
@Html.HiddenFor(m => m.DocumentImageId)
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
âŠ
</form>
- Anti-Forgery Token for CSRF protection
- Hidden Fields ensure state (e.g., whether preview mode is on)
4.2 Rendering Results Table
Once Model.ImagingList contains items:
<h4 class="card-title">Documents List</h4>
<table id="datatable-buttons" class="table table-bordered dt-responsive nowrap">
<thead>
<tr>
<th>Document Type</th>
<th>Document Name</th>
<th>Index Searched</th>
<th>View</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ImagingList) {
<tr>
<td>@item.DocumentType</td>
<td>@item.FileName</td>
@foreach (var idx in item.IndexList) {
<td class="indexSearch">(@idx.AttributeName) @idx.IndexValue</td>
}
<td>@Html.ActionLink("View", "ViewDoc", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
<td>@Html.ActionLink("Edit", "Edit", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
<td>@Html.ActionLink("Delete", "DeleteUploadedDocument", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
</tr>
}
</tbody>
</table>
- Dynamic columns for each
IndexItem - ActionLink generates anchor tags pointing to controller actions
4.3 Action Links (View/Edit/Delete)
| Button | Action Method | Controller | Route Values | Behavior |
|---|---|---|---|---|
| View | ViewDoc(int id) |
AccountingImaging |
id |
Opens new tab |
| Edit | Edit(int id) |
AccountingImaging |
id |
Opens new tab |
| Delete | DeleteUploadedDocument(id) |
AccountingImaging |
id |
Opens new tab |
4.4 Responsive Design & Styles
@media (max-width: 800px) {
.searchSection { flex-direction: column; }
}
.expired { background-color: #f8d7da !important; }
.expiresSoon { background-color: #fff3cd !important; }
.expireWarning { background-color: #ffeeba !important; }
- Media Query for mobile layouts
- Row Highlighting:
- Rows that have passed expiration â
.expired - †30 days â
.expiresSoon - 31â90 days â
.expireWarning
- Rows that have passed expiration â
5. Helper Methods & Utilities
- HTML Helpers:
@Html.HiddenFor(...),@Html.ValidationSummary(),@Html.ActionLink()
- DataTables Integration:
- Initialization with Buttons (
csv,excel,print) - Custom
fnCreatedRowlogic for dateâbased styling
- Initialization with Buttons (
$('#datatable-buttons').dataTable({
dom: 'Bfrtip',
processing: true,
filter: true,
buttons: ['csv','excel','print'],
fnCreatedRow: function (nRow) {
var row = $(nRow);
var txt = row.find('.indexSearch').text().toLowerCase();
if (txt.includes('expiration date')) { /* calculate days to expiry and add class */ }
}
});
- Spinner (spin.js) for loading indicator
6. API Endpoints Overview
| HTTP Verb | Endpoint | Purpose |
|---|---|---|
| POST | /AccountingImaging/Search |
Perform search, return this view |
| GET | /AccountingImaging/ViewDoc/{id} |
View document in new tab |
| GET | /AccountingImaging/Edit/{id} |
Edit document in new tab |
| GET | /AccountingImaging/DeleteUploadedDocument/{id} |
Delete selected document |
| (Commented) | /LegalImaging/PreLoadFormDataBasedOnDropdown |
AJAX formâpreload (unused) |
â Note: Several jQueryâbased AJAX scripts are commented out and not active.
7. Third-Party Integrations
- jQuery for DOM manipulation
- DataTables & Buttons Extension for interactive tables
- jsZip, pdfMake for exporting data
- ApexCharts & Google Charts (referenced but not used directly)
- Spin.js for loading spinners
8. Sample Code Blocks
Initializing DataTables
$('#datatable-buttons').dataTable({
dom: 'Bfrtip',
buttons: ['csv','excel','print'],
fnCreatedRow: function (nRow) {
// Example: Add .expired class if date passed
var txt = $(nRow).find('.indexSearch').text();
if (txt.toLowerCase().includes('expiration date')) {
// parse and compute difference...
$(nRow).addClass('expired');
}
}
});
Razor Loop for Dynamic Columns
@foreach (var item in Model.ImagingList) {
<tr>
<td>@item.DocumentType</td>
@foreach (var idx in item.IndexList) {
<td class="indexSearch">(@idx.AttributeName) @idx.IndexValue</td>
}
<!-- action links⊠-->
</tr>
}
9. Usage Example
-
Controller action:
[HttpPost] public IActionResult Search(DocumentImaging model) { // Populate model.ImagingList based on search criteria... return View("SearchResults", model); } -
Render in parent view:
@Html.Partial("SearchResults", Model.DocumentImaging) -
Result
- User sees a searchable, paged, exportable table
- Rows are colorâcoded for expiring documents
10. UML Diagrams
10.1 Class Diagram (Mermaid)
classDiagram
DocumentImaging --> ImagingItem : contains
ImagingItem --> IndexItem : contains
class DocumentImaging {
+bool Preview
+int DocumentImageId
+List~ImagingItem~ ImagingList
}
class ImagingItem {
+int DocumentImageId
+string DocumentType
+string FileName
+List~IndexItem~ IndexList
}
class IndexItem {
+string AttributeName
+string IndexValue
}
10.2 Sequence Diagram (Mermaid)
sequenceDiagram
participant User
participant Browser
participant Controller
participant SearchResultsView
User->>Browser: Submits Search Form
Browser->>Controller: POST /AccountingImaging/Search
Controller->>Controller: Query DB, build DocumentImaging
Controller->>Browser: Return SearchResults.cshtml + Model
Browser->>SearchResultsView: Render HTML + JS
SearchResultsView->>DataTables: Initialize table & styling
Browser->>User: Display interactive table
11. Conclusion
â SearchResults.cshtml is a featureârich view designed to:
- Display scanned documents in a DataTable
- Provide export, sorting, and filtering capabilities
- Highlight documents based on expiration rules
- Offer View/Edit/Delete actions for each record
With its modular Razor syntax, robust JavaScript integrations, and responsive design, this view forms the backbone of the Accounting Imaging search functionality in the IrbyImaging suite.
Feel free to extend the JavaScript logic (e.g., customize expiration thresholds), refine CSS, or integrate additional plugins to meet evolving requirements!
Authored with â€ïž by Your DevOps Team