📄 deleteModal.cshtml Documentation


📑 Table of Contents

  1. Overview & Purpose
  2. File Summary
  3. Key Functional Areas
  4. Dependencies & Technologies
  5. View Model & Data Models
  6. API Endpoints Overview
  7. Detailed Code Walkthrough
    • 7.1. Modal Structure
    • 7.2. PDF Embed Preview
    • 7.3. Footer Buttons
  8. Helper Methods & Utilities
  9. Error Handling & Return Types
  10. Third‑Party Integrations
  11. Usage Examples
  12. UML Diagram
  13. Conclusion

1. Overview & Purpose

deleteModal.cshtml is an ASP.NET Core Razor View used in the LegalImaging area of the IrbyImaging web application. Its primary purpose is to:

  • Display a modal dialog containing a PDF preview of a document slated for deletion.
  • Provide Print and Close actions for end users.
  • Leverage Bootstrap 5 for styling and modal behavior.

This modal is typically invoked when a user chooses to review (and optionally confirm) the deletion of a scanned document. It ensures they can see the document’s contents before finalizing the delete operation.


2. File Summary

Property Details
Path Views/LegalImaging/deleteModal.cshtml
Model IrbyImaging.Models.DocumentImaging
Purpose Preview & confirm deletion of a document PDF
Layout Partial view (modal only)
Framework ASP.NET Core MVC, Razor, Bootstrap 5

3. Key Functional Areas

  1. Modal Header

    • Title (“Document Details”)
    • Close button (×)
  2. Modal Body

    • Embedded PDF viewer (<embed>)
    • Dynamically fetches PDF via a controller action
  3. Modal Footer

    • Print Document button
    • Close button

4. Dependencies & Technologies

  • ASP.NET Core MVC
  • Razor View Engine
  • Bootstrap 5 (modal, grid, buttons)
  • JavaScript (Bootstrap’s modal JS)
  • PDF Embed via native HTML <embed>

5. View Model & Data Models

IrbyImaging.Models.DocumentImaging

Property Type Description
DocumentImageId int Primary key / identifier for image
(Other fields…) … e.g., FileName, UploadedDate, etc.

Note: Only DocumentImageId is used in this view to stream the PDF.


6. API Endpoints Overview

This view calls a controller action to render the PDF:

  • Controller: LegalImagingController
  • Action: RenderDeleteImagePrev(int id, bool preview)
  • Route: /LegalImaging/RenderDeleteImagePrev/{id}?preview=true
  • Return Type: FileStreamResult (application/pdf)
public IActionResult RenderDeleteImagePrev(int id, bool preview)
{
    // Lookup the file bytes by id
    byte[] pdfBytes = _service.GetDocumentPdf(id);
    return File(pdfBytes, "application/pdf", enableRangeProcessing: true);
}

7. Detailed Code Walkthrough

@model IrbyImaging.Models.DocumentImaging

<div class="modal-content" style="height: 100%;">
  <!-- 1. Modal Header -->
  <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>

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

  <!-- 3. Modal Footer -->
  <div class="modal-footer">
    <button type="button"
            class="btn btn-secondary"
            onclick="window.print()">
      📄 Print Document
    </button>
    <button type="button"
            class="btn btn-secondary"
            data-bs-dismiss="modal">
      ❌ Close
    </button>
  </div>
</div>

7.1. Modal Structure

  • .modal-content: Wraps header/body/footer.
  • Inline styles control height for full-screen embedding.

7.2. PDF Embed Preview

  • <embed> tag requests PDF from the RenderDeleteImagePrev endpoint.
  • Querystring preview=true can toggle thumbnail vs. full PDF.
  • Appends #zoom=FitH to auto-fit PDF width.
  • Print Document: Calls window.print() to print the embedded PDF.
  • Close: Dismisses the modal via Bootstrap’s data attributes.

8. Helper Methods & Utilities

  • Url.Action(...): Generates correct URL for the PDF streaming endpoint.
  • #zoom=FitH: PDF.js / browser-native parameter to fit width on load.

9. Error Handling & Return Types

  • Controller should handle missing IDs or missing files by returning an HTTP 404 or a friendly error PDF.
  • If the PDF fails to load, the embed area will show the browser’s default “Failed to load PDF” message.

10. Third‑Party Integrations

  • Bootstrap 5 Modal
  • Browser-native PDF engine (or PDF.js in Chrome/Edge/Firefox)

11. Usage Examples

Parent View Trigger

<button
  type="button"
  class="btn btn-danger"
  data-bs-toggle="modal"
  data-bs-target="#deleteModal"
  data-id="@Model.DocumentImageId">
  Delete Document
</button>

<div
  class="modal fade"
  id="deleteModal"
  tabindex="-1"
  aria-hidden="true">
  <div class="modal-dialog modal-xl">
    <div class="modal-content">
      @await Html.PartialAsync("deleteModal", Model)
    </div>
  </div>
</div>

Controller Action (Reference)

[HttpGet]
public IActionResult Delete(int id)
{
    var doc = _context.DocumentImaging.Find(id);
    if (doc == null) return NotFound();
    return PartialView("deleteModal", doc);
}

12. UML Diagram

+------------------------+
| DocumentImaging Model  |
+------------------------+
           |
           | passed as @model
           v
+------------------------+
|  deleteModal.cshtml    |  <--- uses Url.Action to
+------------------------+       call RenderDeleteImagePrev()
           |
           v
+------------------------+
| LegalImagingController |
| + RenderDeleteImagePrev(id, preview) |
+------------------------+

13. Conclusion

The deleteModal.cshtml view provides a sleek, Bootstrap‑powered modal that:

  • Streams a PDF preview of a document
  • Enables users to print or close the modal
  • Integrates seamlessly with ASP.NET Core MVC and the LegalImagingController

By encapsulating the preview logic in a reusable partial view, the application maintains a consistent UX and clean separation of concerns. Feel free to extend the modal—such as adding Delete confirmation buttons or thumbnails—to match your project’s business requirements.


Happy coding! 🚀