DeleteUploadedDocument.cshtml Documentation 📄🗑️


Table of Contents

  1. Overview & Purpose
  2. File Location & Naming
  3. Dependencies & Technologies
  4. Model Binding & ViewData
  5. Layout, Styles & CSS
  6. Form Structure & Actions
  7. Rendering Document Thumbnails
  8. JavaScript & Client‐Side Utilities
  9. API Endpoints & AJAX Calls
  10. UML Sequence Diagram
  11. Sample Usage & Code Snippets
  12. Conclusion

1. Overview & Purpose

DeleteUploadedDocument.cshtml is an ASP.NET Razor view under the AccountingImaging feature area. It provides a UI for:

  • Displaying a grid of uploaded documents (PDF previews).
  • Allowing users to select one or more documents.
  • Confirming and performing deletion of the selected documents.
  • Previewing individual documents in a modal dialog.

This view is commonly used by accounting or administrative staff to clean up or remove obsolete scanned documents from the system.


2. File Location & Naming

Property Value
Project IrbyImaging
Area/Folder Views/AccountingImaging
File Name DeleteUploadedDocument.cshtml

3. Dependencies & Technologies

Dependency / Library Purpose
ASP.NET Core MVC (Razor Pages) Server‐side view templating
Bootstrap 4/5 Responsive layout, modals, buttons
jQuery DOM manipulation, AJAX
Bootstrap Datepicker (Optional) date controls
Dropzone.js (Prepared) drag‐and‐drop file uploads styling
TinyMCE Rich‐text (unused in this view)

Key Scripts & Styles are registered in <head> and at bottom:

<link href="~/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet">
<script src="~/assets/libs/jquery/jquery.min.js"></script>
<script src="~/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- datepicker, tinymce, etc. -->

4. Model Binding & ViewData

ViewModel: IrbyImaging.Models.DocumentImaging

public class DocumentImaging
{
  public Guid DocumentImageId { get; set; }
  public List<Guid> BatchIds { get; set; }
  public bool IsLegalDocument { get; set; }
  public bool IsSafety { get; set; }
  public bool IsIT { get; set; }
  public bool IsAccounting { get; set; }
  public bool IsBidding { get; set; }
  public bool DeleteFiles { get; set; }
}
  • ViewData["Title"] is set to “Delete Uploaded Document”.
  • A category string is derived for use in the form (e.g., "legal", "safety", "it", etc.).
  • BatchIds: List of document GUIDs to display.

5. Layout, Styles & CSS

  1. Inline Styles

    .flex-container { display: flex; flex-wrap: wrap; }
    .flex-container > div { background: #f1f1f1; width:50px; /* ... */ }
    
  2. Section Styles
    Registered via @section styles { ... }.

  3. Bootstrap Grid
    Uses .row and .col-md-3 to arrange document thumbnails in a 4‐per‐row layout.


6. Form Structure & Actions

@using (Html.BeginForm("Delete", "LegalImaging", FormMethod.Post, model))
{
  @Html.HiddenFor(m => m.DocumentImageId)
  @Html.HiddenFor(m => m.BatchIds)
  <input type="hidden" id="category" name="category" value="@category" />
  <button type="submit" onclick="deleteFiles();" class="btn btn-danger">
    🗑️ Delete Selected Documents
  </button>
  <!-- Document Thumbnails... -->
}
  • Action: LegalImagingController.Delete( DocumentImaging model )
  • Hidden Fields:
    • DocumentImageId: Single document batch group.
    • BatchIds: IDs of each document.
    • category: Derived string category.
    • DeleteFiles: Flag toggled by JS deleteFiles() when confirmed.

7. Rendering Document Thumbnails

For each GUID in Model.BatchIds:

<div class="col-md-3">
  <div class="thumbnail">
    <embed src="@Url.Action("DeletePreview","AccountingImaging",new { id = docId })#zoom=FitH" type="application/pdf">
    <div class="preference">
      <label>Select</label>
      <input class="checkBoxClass" type="checkbox" name="docIds" value="@docId" />
    </div>
    <a href="javascript:void(0);" class="previewDetail2" data-id="@docId">🔍 Preview</a>
  </div>
</div>
  • PDF Preview is embedded inline with Zoom‐to‐Fit.
  • Checkbox: Each doc gets name="docIds" for multi‐select postback.
  • “Preview” Link: Triggers AJAX to show full preview in a modal.

8. JavaScript & Client‐Side Utilities

8.1. Delete Confirmation

function deleteFiles() {
  var r = confirm("Are you sure you want to delete the selected documents?");
  if (!r) return false;
  $("#DeleteFiles").val("True");
}
  • Prompts user before deletion.
  • Sets hidden field DeleteFiles = True to indicate action.

8.2. “Select All” Toggle

$("#ckbCheckAll").click(function() {
  $(".checkBoxClass").prop('checked', $(this).prop('checked'));
});

8.3. AJAX Preview in Modal

var TeamDetailPostBackURL = '/AccountingImaging/myModalDeletePreview';

$(".previewDetail2").click(function() {
  var id = $(this).data('id');
  $.ajax({
    type: "GET",
    url: TeamDetailPostBackURL,
    data: { id: id, Preview: true },
    success: function (data) {
      $('#myModalContent').html(data);
      $('#myModal').modal('show');
    },
    error: function () {
      alert("Dynamic content load failed.");
    }
  });
});
  • Loads detailed PDF viewer via AJAX into a Bootstrap modal.

9. API Endpoints & AJAX Calls

Endpoint HTTP Verb Parameters Description
/LegalImaging/Delete POST DocumentImaging Deletes selected documents.
/AccountingImaging/myModalDeletePreview GET id (GUID), Preview=Bool Returns partial view with PDF preview.

10. UML Sequence Diagram

sequenceDiagram
    participant User
    participant View as DeleteUploadedDocument.cshtml
    participant Controller as LegalImagingController
    participant Service as ImagingService
    User->>View: Select checkboxes & click Delete
    View->>User: Confirm("Are you sure?")
    View->>Controller: POST /Delete(model)
    Controller->>Service: DeleteDocuments(model.BatchIds)
    Service-->>Controller: DeletionResult
    Controller-->>View: RedirectToAction / Success/Failure

11. Sample Usage & Code Snippets

11.1. On “Delete Selected Documents” Button Click

<button type="submit" onclick="deleteFiles();" class="btn btn-danger">
  🗑️ Delete Selected Documents
</button>

11.2. Preview AJAX Call Example

$.ajax({
  type: "GET",
  url: "/AccountingImaging/myModalDeletePreview",
  data: { id: "123e4567-e89b-12d3-a456-426614174000", Preview: true },
  success: function(html) {
    $('#myModalContent').html(html);
    $('#myModal').modal('show');
  }
});

12. Conclusion

This DeleteUploadedDocument.cshtml view provides a robust, user‐friendly interface for bulk deleting PDF documents within the AccountingImaging module. It leverages ASP.NET MVC Razor for server‐side rendering, Bootstrap for layout and modals, and jQuery for client‐side interactivity. Key highlights include:

  • Multi‐select deletion with confirmation.
  • PDF inline preview and modal view for document inspection.
  • Clean integration with backend controller actions (LegalImaging/Delete).
  • Category tagging via a hidden input to support multi‐category workflows.

By following this documentation, developers can maintain, extend, or integrate this view into broader document‐management workflows seamlessly. 🚀