🚀 Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Models & Data Models
  5. Code Walkthrough
  6. API Endpoints Overview
  7. Helper Methods & Utilities
  8. Third‑Party Integrations
  9. Error Handling & Return Types
  10. UML Class Diagram
  11. Sample Code Blocks
  12. Usage Examples
  13. Conclusion

📋 1. Overview & Purpose

File: IrbyImaging/Views/LegalImaging/_myModalDet.cshtml
This Razor Partial View renders a Bootstrap modal to display document details in two modes:

  • Preview Mode: Embeds the document (PDF/image) for inline viewing.
  • Non-Preview Mode: Shows the OCR‑extracted text.

Intended Use:

  • Called from any parent view to pop up document details.
  • Makes use of the IrbyImaging.Models.DocumentImaging model.

🔑 2. Key Functional Areas

Section Purpose
Modal Header Displays the title & close button
Preview Body Shows embedded PDF/image via the RenderImage action
Text Body Presents OCR text when preview is disabled
Modal Footer Provides action buttons (e.g., Close)

🛠️ 3. Dependencies & Technologies

  • ASP.NET MVC / Razor Pages
  • Bootstrap 5 Modal (data-bs-* attributes)
  • jQuery (optional for advanced triggers)
  • Browser PDF/embed support

📦 4. View Models & Data Models

DocumentImaging Model

namespace IrbyImaging.Models
{
    public class DocumentImaging
    {
        public bool Preview { get; set; }            // Toggle inline viewing
        public string DocumentType { get; set; }     // e.g. "Invoice"
        public string DocumentCategory { get; set; } // e.g. "Legal"
        public int DocumentImageId { get; set; }     // Primary key for retrieval
        public string ImageOCRText { get; set; }     // Extracted text for search/index
    }
}

🔍 5. Code Walkthrough

5.1 Modal Header

<div class="modal-header">
  <h5 class="modal-title" id="transaction-detailModalLabel">Document Details</h5>
  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
  • .modal-title: Static header label.
  • Close button: Uses data-bs-dismiss="modal" to auto‑close.

5.2 Preview Mode

@if (Model.Preview) {
  <div style="height: 600px">
    <div class="modal-body" style="height: 100%;">
      <p>Document Type: <span class="text-primary">@Html.DisplayFor(m => m.DocumentType)</span></p>
      <p>Document Category: <span class="text-primary">@Html.DisplayFor(m => m.DocumentCategory)</span></p>
      <embed 
        src="@Url.Action("RenderImage", "LegalImaging", new { id = Model.DocumentImageId, preview = true })#zoom=FitH" 
        type="application/pdf" width="100%" height="100%" />
    </div>
  </div>
}
  • Model.Preview == true: Embeds a PDF with full-width/height.
  • #zoom=FitH: Auto‑fits horizontally.

5.3 Non-Preview Mode

@if (!Model.Preview) {
  <div class="modal-body">
    <p>Document Type: <span class="text-primary">@Model.DocumentType</span></p>
    <p>Document Category: <span class="text-primary">@Model.DocumentCategory</span></p>
    <div class="table-responsive">
      <span style="white-space: pre-wrap">@Model.ImageOCRText</span>
    </div>
  </div>
}
  • OCR Text: Wrapped in pre-wrap to preserve formatting & line breaks.
  • Responsive container: Ensures long text scrolls gracefully.
<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
  • Only Close action is provided; you may extend it (e.g., Print).

🌐 6. API Endpoints Overview

Endpoint Controller Description
/LegalImaging/RenderImage?id={id}&preview=true LegalImagingController Returns the binary of the document as PDF or image.
public IActionResult RenderImage(int id, bool preview) 
{
    // Fetch byte[] from repository based on id
    // return File(bytes, "application/pdf");
}

🧰 7. Helper Methods & Utilities

  • @Html.DisplayFor(...): Strong‑typed display of model properties.
  • @Url.Action(...): Generates URL for the RenderImage endpoint.

🔗 8. Third‑Party Integrations

  • Bootstrap 5 for modal UI/UX.
  • Browser’s built‑in PDF viewer for <embed> tag.

⚠️ 9. Error Handling & Return Types

  • Missing Document: Controller should return NotFound() if id not found.
  • Unsupported Format: Return HTTP 415 if file is not PDF/image.
  • Large Files: Consider streaming with FileStreamResult to reduce memory pressure.

📊 10. UML Class Diagram

classDiagram
  class DocumentImaging {
    +bool Preview
    +string DocumentType
    +string DocumentCategory
    +int DocumentImageId
    +string ImageOCRText
  }

  class LegalImagingController {
    +IActionResult RenderImage(int id, bool preview)
  }
  
  DocumentImaging --> LegalImagingController : uses

💻 11. Sample Code Blocks

Parent View – Triggering the Modal

<!-- Button to open modal -->
<button 
  class="btn btn-primary" 
  data-bs-toggle="modal" 
  data-bs-target="#transactionDetailModal">
  View Document
</button>

<!-- Modal container -->
<div 
  class="modal fade" 
  id="transactionDetailModal" 
  tabindex="-1" 
  aria-labelledby="transaction-detailModalLabel" 
  aria-hidden="true">
  <div class="modal-dialog modal-xl">
    @Html.Partial("_myModalDet", Model.DocumentModel)
  </div>
</div>

Controller Snippet

public class LegalImagingController : Controller
{
    public IActionResult Details(int id, bool preview = true)
    {
        var doc = _repo.GetDocumentImaging(id);
        if (doc == null) return NotFound();
        doc.Preview = preview;
        return PartialView("_myModalDet", doc);
    }

    public IActionResult RenderImage(int id, bool preview)
    {
        var fileBytes = _repo.GetFileBytes(id);
        return File(fileBytes, "application/pdf");
    }
}

📚 12. Usage Examples

  1. Inline Preview
    @Html.Action("Details", "LegalImaging", new { id = 123, preview = true })
    
  2. OCR Text Only
    @Html.Action("Details", "LegalImaging", new { id = 123, preview = false })
    

🎯 13. Conclusion

The _myModalDet.cshtml partial view provides a flexible, reusable Bootstrap modal for displaying document details. By toggling the Preview flag, you can seamlessly switch between an embedded PDF viewer and plain-text OCR output. Leverage this component across your LegalImaging module to ensure consistent UI/UX when reviewing or processing documents.

Feel free to extend the footer with additional actions—such as Print, Download, or Approve—to tailor it to your workflow!


Generated with ❤️ for IrbyImaging