📄 IrbyImaging/Views/Imaging/Edit.cshtml Documentation
🗂 Table of Contents
- 🔍 Overview & Purpose
- 📁 File Location & Structure
- ⚙️ Dependencies & Technologies
- 📦 ViewModel: DocumentImaging
- 🎯 Key Functional Areas
- 🛣 API Endpoints Overview
- 🔗 Third‑party Integrations
- 📈 UML Diagrams
- 💡 Usage Examples
- ✅ Conclusion & Takeaways
🔍 Overview & Purpose
The Edit.cshtml Razor view serves as the user interface for:
- Attaching one or more files to an existing DocumentImaging record
- Editing metadata (type, job info, owner, dates, notes, etc.) of an uploaded document
- Previewing the current PDF in an embedded viewer
This page is part of the Imaging area in an ASP.NET MVC application, enabling users to maintain and update digital document records.
📁 File Location & Structure
IrbyImaging/
└── Views/
└── Imaging/
└── Edit.cshtml
- Layout:
~/Views/Shared/_Layout.cshtml - Model:
IrbyImaging.Models.DocumentImaging
⚙️ Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| ASP.NET MVC Razor (@model, Html.BeginForm) | Templating, forms, validation |
| Bootstrap | Grid, cards, buttons, form controls |
| Bootstrap‑Datepicker | Date input styling |
| Dropzone | (CSS only) file drag‑and‑drop styling |
| jQuery | DOM manipulation |
| Select2 | Enhanced searchable dropdowns |
| TinyMCE | Rich text editor (loaded but not used here) |
| jQuery Repeater | Dynamic form sections (markup present but unused) |
| MetisMenu, Simplebar, Node‑Waves | UI plugins (sidebar/menu behavior) |
📦 ViewModel: DocumentImaging
This Razor view binds to the DocumentImaging model. Key properties include:
| Property | Type | Description |
|---|---|---|
Guid DocumentImageId |
Guid |
Unique ID of the document image record |
string BlobName |
string |
Azure Blob filename |
List<Guid> BatchIds |
List<Guid> |
Batch grouping identifiers |
string DocumentType |
string |
Type/category of the document |
string JobNumber |
string |
Associated job identifier |
string JobName |
string |
Name/title of the job |
string JobOwner |
string |
Owner/person responsible for the job |
string UnitNumber |
string |
Equipment or unit number |
string AssignedToEmployeeId |
string |
Employee ID assigned to handle the document |
string AssignedToEmployeeName |
string |
Employee name |
string WorkOrder |
string |
Work order reference |
string CompletedBy |
string |
Person who completed the work |
DateTime DocumentUploadedDate |
DateTime |
Date of document upload/creation |
string DocumentNotes |
string |
Free‑text notes or description |
🎯 Key Functional Areas
1️⃣ Styles Section
@section styles {
<!-- Datepicker CSS -->
<link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<!-- Dropzone CSS -->
<link href="~/libs/dropzone/min/dropzone.min.css" rel="stylesheet" type="text/css" />
}
- Purpose: Pull in styles for the datepicker widget and optional drag‑and‑drop file upload UI.
2️⃣ Attach Additional Documents Form
@using (Html.BeginForm("Attach","Imaging",FormMethod.Post, new { enctype="multipart/form-data" })) {
@Html.HiddenFor(m => m.DocumentImageId)
<div class="card">
<div class="card-body">
<h4 class="card-title mb-4">Attach Additional Documents</h4>
<input type="file" name="file" class="form-control" multiple />
<button id="submitbtn" type="submit" class="btn btn-primary">Attach</button>
</div>
</div>
}
- Action: POST to
ImagingController.Attach(Guid docId, IFormFile[] files, ...) - Key Fields:
file(multiple) – file inputs- Hidden
DocumentImageId– correlates attachments to the record
3️⃣ Edit Document Metadata Form
@using (Html.BeginForm("Edit","Imaging",FormMethod.Post)) {
@Html.HiddenFor(m => m.DocumentImageId)
@Html.HiddenFor(m => m.BlobName)
@*... form fields for DocumentType, JobNumber, JobName, etc. *@
<button id="saveDocument" type="submit" class="btn btn-primary">Save Document</button>
}
Highlights
- Select Controls:
DocumentType– hard‑coded<select>with ~25 optionsJobNumber– populated viaasp-items="@ViewBag.JobNames"EmployeeId– populated viaasp-items="@ViewBag.Employees"
- Textareas: for names, owner, unit number, notes
- Date Picker:
@Html.TextBoxFor(m => m.DocumentUploadedDate, "{0:d}", new { @type="date" })
4️⃣ PDF Preview
<embed id="frPDF" width="100%" height="100%"
src="@Url.Action("EditDocumentPreview","Imaging", new { id=Model.DocumentImageId })#zoom=FitH"
type="application/pdf">
- Embeds the document PDF for instant preview without leaving the page.
5️⃣ JavaScript & Interactivity
$(document).ready(function(){
$('#JobNumberList, #DocumentType, #EmployeeId').select2();
});
$('#JobNumberList').on("change", function(){
var parts = $(this).val().split('-');
$('#JobName').val(parts.slice(1).join('-'));
});
$('#EmployeeId').on("change", function(){
var parts = $(this).val().split('-');
// infer "First Last" from "ID-Last,First"
var nameParts = parts.slice(1).join('').split(',');
$('#EmployeeName, #CompletedBy').val(nameParts.reverse().join(' '));
});
- Select2: Makes dropdowns searchable
- Dynamic Field Population:
- JobName updates when
JobNumberchanges - EmployeeName & CompletedBy auto‑fill
- JobName updates when
🛣 API Endpoints Overview
| Endpoint | HTTP Method | Purpose |
|---|---|---|
/Imaging/Edit/{id} |
GET | Render this Edit view with DocumentImaging model |
/Imaging/Attach |
POST | Receive file(s) and attach to existing record |
/Imaging/Edit |
POST | Save updated metadata for the document |
/Imaging/EditDocumentPreview |
GET | Return PDF stream for preview |
🔗 Thirdparty Integrations
- Bootstrap‑Datepicker – date picker control
- Dropzone (CSS) – stylized drag & drop
- Select2 – enhanced selects
- jQuery Repeater – dynamic forms scaffolding (unused scaffolding present)
- TinyMCE – rich text (loaded but no editor instance initialized here)
📈 UML Diagrams
1. Sequence Diagram
sequenceDiagram
participant User
participant Browser
participant ImagingController
participant StorageService
User->>Browser: Navigate to /Imaging/Edit/{id}
Browser->>ImagingController: GET Edit(id)
ImagingController->>Browser: Returns Edit.cshtml + Model
User->>Browser: Choose files & metadata
Browser->>ImagingController: POST /Attach (files)
ImagingController->>StorageService: Upload files
StorageService-->>ImagingController: Returns blob names
ImagingController-->>Browser: Redirect back to Edit
User->>Browser: Update metadata form & Submit
Browser->>ImagingController: POST /Edit (metadata)
ImagingController->>Database: Save changes
ImagingController-->>Browser: Redirect/Success
2. Class Diagram
classDiagram
class DocumentImaging {
+Guid DocumentImageId
+string BlobName
+List<Guid> BatchIds
+string DocumentType
+string JobNumber
+string JobName
+string JobOwner
+string UnitNumber
+string AssignedToEmployeeId
+string AssignedToEmployeeName
+string WorkOrder
+string CompletedBy
+DateTime DocumentUploadedDate
+string DocumentNotes
}
💡 Usage Examples
Rendering the View
public IActionResult Edit(Guid id) {
var model = _documentService.GetDocumentImagingById(id);
ViewBag.JobNames = new SelectList(_jobService.GetJobList(), "Value", "Text");
ViewBag.Employees = new SelectList(_employeeService.GetEmployees(), "Value", "Text");
return View(model);
}
Posting Attach Form
[HttpPost]
public IActionResult Attach(Guid docId, List<IFormFile> file) {
// Loop files, upload to Azure Blob, save references
_imagingService.AttachFiles(docId, file);
return RedirectToAction("Edit", new { id = docId });
}
Posting Metadata Form
[HttpPost]
public IActionResult Edit(DocumentImaging model) {
if (!ModelState.IsValid)
return View(model);
_imagingService.UpdateDocumentMetadata(model);
TempData["Success"] = "Document saved successfully!";
return RedirectToAction("Edit", new { id = model.DocumentImageId });
}
✅ Conclusion & Takeaways
- Edit.cshtml provides a comprehensive interface for both file attachments and metadata editing of document records.
- Leverages ASP.NET MVC helpers, third‑party plugins (Select2, Datepicker), and embedded PDF to give end‑users a smooth experience.
- Dynamic JavaScript simplifies data entry by auto‑populating related fields.
- Modular forms separate concerns: one for attachments, one for metadata.
Happy coding! 🚀