📄 _myModalDet.cshtml Documentation

Path: IrbyImaging/Views/HRImaging/_myModalDet.cshtml
Type: Razor Partial View (Modal for Document Details)


🗂 Table of Contents

  1. Overview & Purpose
  2. File Location & Context
  3. Model Binding
  4. Layout & Structure
  5. Key Functional Areas
  6. API Endpoint Used
  7. Dependencies & Technologies
  8. Model & Data Structure
  9. UML Class Diagram
  10. Sample Usage
  11. Conclusion

🔍 1. Overview & Purpose

This Razor partial view renders a Bootstrap modal that displays the details of a document within the HRImaging area of the IrbyImaging application. Depending on the Preview flag in the bound model:

  • Preview mode: Shows an embedded PDF viewer.
  • Non‑preview mode: Shows OCR‑extracted text in a scrollable container.

Emojis and Bootstrap styling enhance the UI/UX, making document inspection intuitive.


🗺 2. File Location & Context

IrbyImaging/
└─ Views/
   └─ HRImaging/
      └─ _myModalDet.cshtml    ← This file
  • Area: HRImaging
  • Namespace: IrbyImaging.Views.HRImaging
  • Usage: Typically invoked via Html.Partial(...) or RenderPartialAsync(...) inside a parent view.

🧩 3. Model Binding

@model IrbyImaging.Models.DocumentImaging
  • The view expects a DocumentImaging object.
  • Fields used:
    • Preview (bool)
    • DocumentType (string)
    • DocumentCategory (string)
    • DocumentImageId (int)
    • ImageOCRText (string)

📐 4. Layout & Structure

<div class="modal-content">
  <!-- Header -->
  <div class="modal-header"> … </div>

  <!-- Body: Preview or Non-Preview -->
  @if (Model.Preview) { … } 
  @if (!Model.Preview) { … }

  <!-- Footer -->
  <div class="modal-footer"> … </div>
</div>

🎯 5. Key Functional Areas

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>
  • Title: “Document Details” with an emoji.
  • Close Button: Uses Bootstrap’s .btn-close.

5.2. Preview Section

Rendered when Model.Preview == true.

<div style="height: 600px">
  <div class="modal-body" style="height: 100%;">
    <p class="mb-2">Document Type: <span class="text-primary">@Model.DocumentType</span></p>
    <p class="mb-4">Document Category: <span class="text-primary">@Model.DocumentCategory</span></p>
    <embed height="100%" width="100%"
           src="@Url.Action("RenderImage", "HRImaging", new { id = Model.DocumentImageId, preview = true })#zoom=FitH"
           type="application/pdf">
  </div>
</div>
  • Dimensions: Fixed 600px height to accommodate PDF viewer.
  • Embed: Streams PDF via HRImagingController.RenderImage.
  • Zoom: Adds #zoom=FitH in the URL fragment.

5.3. Non‑Preview Section

Rendered when Model.Preview == false.

<div class="modal-body">
  <p class="mb-2">Document Type: <span class="text-primary">@Model.DocumentType</span></p>
  <p class="mb-4">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: Displays extracted text in a scrollable, pre‑wrapped container.

<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
  • Single Close button to dismiss modal.

🔗 6. API Endpoint Used

Endpoint HTTP Verb Description
/HRImaging/RenderImage/{id}?preview= GET Streams the document PDF (or image) for in-browser embed.
  • Controller: HRImagingController
  • Action: RenderImage(int id, bool preview)

⚙️ 7. Dependencies & Technologies

Technology Role
ASP.NET MVC Controller/Action routing & model binding
Razor Syntax Server‑side templating
Bootstrap 5 Modal & responsive UI components
HTML <embed> In‑browser PDF rendering
C# Model Class Strongly‑typed view data

📦 8. Model & Data Structure

8.1. DocumentImaging Model

namespace IrbyImaging.Models
{
    public class DocumentImaging
    {
        public bool   Preview           { get; set; }
        public string DocumentType      { get; set; }
        public string DocumentCategory  { get; set; }
        public int    DocumentImageId   { get; set; }
        public string ImageOCRText      { get; set; }
    }
}
Property Type Description
Preview bool Toggle between PDF embed or OCR text display
DocumentType string Friendly name of the document type
DocumentCategory string Category classification
DocumentImageId int Identifier for backend image retrieval
ImageOCRText string Extracted text via OCR for display

🧑‍💻 9. UML Class Diagram

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

🚀 10. Sample Usage

Parent View Example

@model IrbyImaging.Models.SomeParentViewModel

<button class="btn btn-primary"
        data-bs-toggle="modal"
        data-bs-target="#[email protected]">
  View Document
</button>

<div class="modal fade"
     id="[email protected]"
     tabindex="-1"
     aria-labelledby="transaction-detailModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-xl">
    @Html.Partial("_myModalDet", Model.DocumentImaging)
  </div>
</div>

Controller Endpoint Sketch

public class HRImagingController : Controller
{
    public IActionResult RenderImage(int id, bool preview)
    {
        var doc = _service.GetDocumentById(id);
        var stream = preview
            ? doc.GetPdfStream()
            : doc.GetImageStream();

        return new FileStreamResult(stream, "application/pdf");
    }
}

🏁 11. Conclusion

This partial view delivers a dynamic, reusable modal for inspecting document details in the HR Imaging module. By leveraging Razor, Bootstrap, and a well‑defined model, it cleanly separates concerns:

  • Presentation logic in the view (_myModalDet.cshtml)
  • Rendering logic in the controller (RenderImage action)
  • Data structure in the DocumentImaging model

🎉 You can now integrate this modal anywhere in your application, passing different DocumentImaging instances to provide an intuitive preview or OCR text display experience!