📄 ViewDocuments.cshtml Documentation

Welcome to the comprehensive documentation for the IrbyImaging/Views/LegalImaging/ViewDocuments.cshtml Razor view. This file powers the Legal Documents page in the Irby Imaging application, enabling users to search, filter, and view PDF documents uploaded by legal teams.


🗂️ Table of Contents

  1. Overview & Purpose
  2. File Location & Layout
  3. Model & ViewModel
  4. Form Structure & Filter Controls
  5. Search Results & DataTable
  6. JavaScript & Third‑Party Libraries
  7. Flow & Integration
  8. UML Class Diagram
  9. Usage Examples
  10. Conclusion

🔍 1. Overview & Purpose

The ViewDocuments.cshtml page allows legal staff to:

  • Filter documents by Upload Date and Document Type.
  • Submit filter criteria using an anti-forgery form.
  • Display the search results in a responsive, paginated table.
  • View individual PDFs in a new browser tab.

This view is part of the LegalImaging area and uses a shared legal-themed layout.


📂 2. File Location & Layout

IrbyImaging/
└── Views/
    └── LegalImaging/
        └── ViewDocuments.cshtml
  • Layout: ~/Views/Shared/_LegalLayout.cshtml
  • ViewData Title: "Documents Page"
@{
    ViewData["Title"] = "Documents Page";
    Layout = "~/Views/Shared/_LegalLayout.cshtml";
}

👥 3. Model & ViewModel

This view is strongly typed to the DocumentImaging model:

@model IrbyImaging.Models.DocumentImaging

Key Properties

Property Type Description
DocumentUploadedDate DateTime Filter: date of upload
DocumentType string Filter: type/category of the document
List SearchResults List<DocumentImaging> Holds search results when the form is submitted
DocumentNotes string Displayed as the document “Name”
ContentType string MIME type of the document
DocumentUploadedBy string Uploader’s username
DocumentImageId int Key used to view the PDF

⚙️ 4. Form Structure & Filter Controls

The top of the page features a Bootstrap-based filter form:

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })

    <div class="row">
        <div class="col-md-4 input-group">
            <span class="input-group-addon">
                <label class="col-form-label">Date</label>
            </span>
            @Html.TextBoxFor(m => m.DocumentUploadedDate, "{0:d}", new { type = "date" })
            @Html.ValidationMessageFor(m => m.DocumentUploadedDate, "", new { @class = "text-danger" })
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 input-group">
            <span class="input-group-addon">
                <label class="col-form-label">Type</label>
            </span>
            @Html.TextBoxFor(m => m.DocumentType)
            @Html.ValidationMessageFor(m => m.DocumentType)
        </div>
    </div>
    <div class="row justify-content-end">
        <div class="col-lg-10">
            <button type="submit" class="btn btn-primary">Submit</button>
        </div>
    </div>
}
  • Anti‑Forgery Token: Protects against CSRF attacks.
  • ValidationSummary/ValidationMessage: Displays model validation errors.

📑 5. Search Results & DataTable

When Model.SearchResults is populated, a DataTable displays the documents:

@if (Model.SearchResults != null && Model.SearchResults.Count > 0) {
    <div class="card">
        <div class="card-body">
            <h4 class="card-title">Documents List</h4>
            <table id="datatable-buttons" class="table table-bordered dt-responsive nowrap w-100">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Document Type</th>
                        <th>Content Type</th>
                        <th>Upload Date</th>
                        <th>Upload By</th>
                        <th>View</th>
                    </tr>
                </thead>
                <tbody>
                @foreach (var item in Model.SearchResults) {
                    <tr>
                        <td>@item.DocumentNotes</td>
                        <td>@item.DocumentType</td>
                        <td>@item.ContentType</td>
                        <td>@item.DocumentUploadedDate:d</td>
                        <td>@item.DocumentUploadedBy</td>
                        <td>
                            @Html.ActionLink(
                                "View PDF",
                                "ViewPdf",
                                "Imaging",
                                new { id = item.DocumentImageId },
                                new { target = "_blank", @class = "btn btn-outline-primary btn-sm" }
                            )
                        </td>
                    </tr>
                }
                </tbody>
            </table>
        </div>
    </div>
}

Columns

Column Binds To
Name DocumentNotes
Document Type DocumentType
Content Type ContentType
Upload Date DocumentUploadedDate (d)
Upload By DocumentUploadedBy
View ImagingController.ViewPdf

🛠️ 6. JavaScript & Third‑Party Libraries

At the bottom of the view, we reference essential scripts for layout, UI, and DataTables:

Library Purpose
jQuery DOM manipulation
Bootstrap Bundle Responsive layout, modals, tooltips
MetisMenu Side menu plugin
SimpleBar Custom scrollbars
Waves Click effect for buttons
DataTables (+ Extensions) Table sorting, paging, exporting
JSZip & pdfmake Excel/PDF export support
<!-- Example -->
<script src="~/libs/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="~/libs/pdfmake/build/pdfmake.min.js"></script>
<script src="~/libs/datatables.net-buttons/js/buttons.print.min.js"></script>
<script src="~/js/pages/datatables.init.js"></script>
<script src="~/js/app.js"></script>

🔄 7. Flow & Integration

  1. User Interaction

    • User selects Date and/or Type.
    • Clicks Submit.
  2. Postback & Controller

    • Form posts to the same action (default).
    • LegalImagingController.ViewDocuments(DocumentImaging model)
    • Controller populates model.SearchResults.
  3. Render Results

    • View re-renders with a populated SearchResults.
    • DataTables plugin enhances the table (search, export).
  4. View PDF

    • Clicking View PDF triggers ImagingController.ViewPdf(int id).
    • Opens the PDF in a new tab (target="_blank").

📊 8. UML Class Diagram

classDiagram
    class DocumentImaging {
        +DateTime DocumentUploadedDate
        +string  DocumentType
        +List<DocumentImaging> SearchResults
        +string  DocumentNotes
        +string  ContentType
        +string  DocumentUploadedBy
        +int     DocumentImageId
    }
    DocumentImaging "1" --> "*" DocumentImaging : SearchResults
  • DocumentImaging is both the filter model and result item in this simplified design.

🚀 9. Usage Examples

Example 1: Simple Filter by Date

<input type="date" name="DocumentUploadedDate" value="2023-08-15" />
<input type="text" name="DocumentType" placeholder="Leave blank for all" />
<button type="submit">Submit</button>
  • Returns all documents uploaded on 2023‑08‑15.

Example 2: Filter by Type Only

<input type="date" name="DocumentUploadedDate" />
<input type="text" name="DocumentType" value="Contract" />
<button type="submit">Submit</button>
  • Returns all ‘Contract’ documents, ignoring the date filter.

🎯 10. Conclusion

ViewDocuments.cshtml is a user-friendly, secure, and extensible Razor view for legal document search and viewing. Key highlights:

  • Robust anti‑forgery protection.
  • Server‑side validation via ValidationSummary.
  • Dynamic, paginated result listing using DataTables.
  • Easy PDF viewing integration with a separate controller action.

Feel free to extend by adding more filters, custom styling, or export options as your application grows!


✨ Happy Coding! ✨