📄 deleteModal.cshtml Documentation

Path: IrbyImaging/Views/HRImaging/deleteModal.cshtml
Type: Razor View (ASP.NET Core MVC)
Model: IrbyImaging.Models.DocumentImaging


📑 Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Models & Data Models
  5. API Endpoint Overview
  6. Sample Code Block
  7. Usage Examples
  8. Error Handling & Return Types
  9. Third‑party Integrations
  10. UML Diagram
  11. Conclusion

🔍 1. Overview & Purpose

This Razor Partial View renders a Bootstrap modal to preview and print a PDF document before deletion (or general detail viewing). Despite being named deleteModal, it is primarily used to display document details (e.g., PDF preview) in a popup window. The modal:

  • Embeds a PDF stream returned by the server.
  • Provides Print and Close actions.
  • Accepts a DocumentImaging model instance containing metadata including the document’s unique DocumentImageId.

Use this partial view in any parent view or controller where you need to show a document preview modal.


🚀 2. Key Functional Areas

Section Description
Modal Header Displays the title Document Details and close button.
PDF Embed Section <embed> tag that renders the PDF returned by /HRImaging/RenderDeleteImagePrev.
Modal Footer Buttons
  • Print Document (placeholder – currently just closes modal)
  • Close (closes the modal) |

🏗️ 3. Dependencies & Technologies

Technology Usage
ASP.NET Core MVC Razor view engine, @model, @Url.Action
Bootstrap 5 Modal styling (modal-content, modal-header, btn-close, etc.)
HTML <embed> tag To embed and render PDF inline (width/height set to 100%)
C# Model Binding @model IrbyImaging.Models.DocumentImaging for strongly typed data access

📦 4. View Models & Data Models

Model: IrbyImaging.Models.DocumentImaging

Property Type Description
DocumentImageId int Unique identifier for the document image
(others…) … (You can extend this model with FileName, CreatedAt, etc.)

Note: The only property used in this view is DocumentImageId to fetch the PDF in the embed.


🔗 5. API Endpoint Overview

The view calls a single API endpoint in the HRImaging controller:

Action Method Route Query Parameters Returns
RenderDeleteImagePrev /HRImaging/RenderDeleteImagePrev id (int), preview (bool) PDF Stream

Route Invocation in View:

@Url.Action(
  "RenderDeleteImagePrev", 
  "HRImaging", 
  new { id = Model.DocumentImageId, preview = true }
)

📋 6. Sample Code Block

@model IrbyImaging.Models.DocumentImaging

<div class="modal-content" style="height: 100%;">
  <div class="modal-header">
    <h5 class="modal-title">Document Details</h5>
    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  </div>

  <div class="modal-body" style="height: 600px;">
    <embed
      src="@Url.Action("RenderDeleteImagePrev", "HRImaging", new { id = Model.DocumentImageId, preview = true })#zoom=FitH"
      type="application/pdf" 
      width="100%" 
      height="100%" />
  </div>

  <div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">🖨️ Print Document</button>
    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">❌ Close</button>
  </div>
</div>

⚙️ 7. Usage Examples

1. Rendering in a Parent View

<!-- Trigger Button -->
<button 
  type="button" 
  class="btn btn-danger" 
  data-bs-toggle="modal" 
  data-bs-target="#[email protected]">
  Delete / Preview
</button>

<!-- Modal Partial -->
<div class="modal fade" id="[email protected]" tabindex="-1">
  <div class="modal-dialog modal-xl">
    @await Html.PartialAsync("deleteModal", Model)
  </div>
</div>

2. JavaScript Control

// Open the modal programmatically
const myModal = new bootstrap.Modal('#deleteModal-123', {});
myModal.show();

👉 Tip: You can wire up an AJAX call to fetch DocumentImaging data, then render this partial via jQuery or Fetch API.


🚨 8. Error Handling & Return Types

  • Client-side:
    • The <embed> will show the browser’s default PDF error if the stream is invalid.
  • Server-side (RenderDeleteImagePrev):
    • Should return File(stream, "application/pdf") or an error status code (404/500).
    • On failure, consider returning a custom error view or JSON for AJAX calls.

🔌 9. Third‑party Integrations

  • Bootstrap 5
  • PDF.js (optional) – if you decide to replace <embed> with a more full‑featured PDF viewer.
  • jQuery / Axios / Fetch – for AJAX modal population.

🧩 10. UML Diagram

classDiagram
    class DocumentImaging {
        +int DocumentImageId
        +string FileName
        +DateTime CreatedAt
        +byte[] Data
    }
    class deleteModal {
        +render(): HTML
    }
    DocumentImaging <|-- deleteModal : uses

✅ 11. Conclusion

The deleteModal.cshtml partial view is a reusable component designed for:

  • 🎯 Previewing PDF documents inline via an <embed> tag.
  • 🖨️ Printing documents directly from the modal.
  • ❌ Closing the popup gracefully.

By hooking it up to your HRImagingController and leveraging Bootstrap’s modal system, you gain a consistent, user‑friendly interface to review documents before deletion or other actions. Feel free to extend the model with additional metadata (e.g., file name, upload date) and customize the footer buttons for actual deletion or archival workflows!