DeleteUploadedDocument.cshtml Documentation đđď¸
Table of Contents
- Overview & Purpose
- File Location & Naming
- Dependencies & Technologies
- Model Binding & ViewData
- Layout, Styles & CSS
- Form Structure & Actions
- Rendering Document Thumbnails
- JavaScript & ClientâSide Utilities
- API Endpoints & AJAX Calls
- UML Sequence Diagram
- Sample Usage & Code Snippets
- 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
-
Inline Styles
.flex-container { display: flex; flex-wrap: wrap; } .flex-container > div { background: #f1f1f1; width:50px; /* ... */ } -
Section Styles
Registered via@section styles { ... }. -
Bootstrap Grid
Uses.rowand.col-md-3to 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 JSdeleteFiles()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 = Trueto 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. đ