📄 Documentation: IrbyImaging/Views/JDE/Index.cshtml
Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- View Model & Data Model
- Layout & Styling
- HTML Structure & Data Binding
- DataTables Integration
- Third‑party Integrations
- API Endpoints Overview
- Sample Usage
- UML Diagram
- Conclusion
1. Overview & Purpose 🚀
Index.cshtml in IrbyImaging/Views/JDE renders the Field Office List page. It:
- Displays a table of field offices stored in the system.
- Shows key details (JDE number, manager, phone, address, etc.).
- Provides Create, Details, and Update actions.
- Integrates DataTables for search, sort, and export functionality.
This view is typically invoked by an action in JDEController (or FieldOfficesController) that returns IEnumerable<FieldOffice>.
2. Key Functional Areas 🔑
- Header & Badge
- Displays the total count of field offices via
@Model.Count().
- Displays the total count of field offices via
- Action Buttons
- Add New Field Office (
asp-action="Create") - Details & Update per row, opening in a new tab.
- Add New Field Office (
- Table Rendering
- Uses Razor
foreachto loopModel. - Leverages
Html.DisplayFor&Html.DisplayNameFor.
- Uses Razor
- DataTables Initialization
- Enables CSV, Excel, and Print buttons.
- Scripts Section
- Imports jQuery, DataTables, PDFMake, JSZip, Bootstrap, etc.
3. Dependencies & Technologies 🔧
| Category | Library / Framework |
|---|---|
| Front‑End | Bootstrap 4, jQuery, DataTables (core, Buttons, Responsive) |
| ASP.NET Core | Razor Pages / MVC, Tag Helpers (asp-action, asp-controller, etc.) |
| Styling | Custom .irby‑blue, .irby‑green, .irby‑orange classes |
| Export Tools | JSZip, PDFMake (for Excel, PDF generation) |
4. View Model & Data Model 🗂️
Model Declaration
@model IEnumerable<IrbyImaging.DomainClasses.FieldOffice>
FieldOffice (DomainClasses)
public class FieldOffice
{
public int Id { get; set; }
public string JdeNumber { get; set; }
public string Name { get; set; }
public int ManagerId { get; set; }
public Employee Manager { get; set; }
public int SuperintendentId { get; set; }
public Employee Superintendent { get; set; }
public int ProjectManagerId { get; set; }
public Employee ProjectManager { get; set; }
public int LeadId { get; set; }
public Employee Lead { get; set; }
public string OfficePhone { get; set; }
public string FaxNumber { get; set; }
public string MailingAddress { get; set; }
}
public class Employee
{
public int Id { get; set; }
public string FullName { get; set; }
}
5. Layout & Styling 🎨
@{
ViewData["Title"] = "Field Office List";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
- Layout: Reuses
_ATSLayout.cshtmlfor consistent header/nav/footer. - Badges and Buttons: Custom CSS classes (
irby-blue,irby-green, etc.) to match corporate palette.
6. HTML Structure & Data Binding 🏗️
<h2>
Field Offices
<span class="badge irby-blue" style="color: #495057;">
@Model.Count()
</span>
</h2>
<div class="row">
<div class="col-lg-2">
<a asp-action="Create" class="btn btn-success irby-green">
Add New Field Office
</a>
</div>
</div>
<table id="fieldOfficesDatatable" class="table table-striped table-bordered dt-responsive nowrap">
<thead>
<tr>
<th>@Html.DisplayNameFor(m => m.JdeNumber)</th>
<th>Field Office Name</th>
<th>@Html.DisplayNameFor(m => m.Manager)</th>
<!-- …other headers… -->
<th>Details</th>
<th>Update</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>@Html.DisplayFor(mi => item.JdeNumber)</td>
<td>@Html.DisplayFor(mi => item.Name)</td>
<td>
<a asp-controller="Employees" asp-action="Details" asp-route-id="@item.ManagerId">
@Html.DisplayFor(mi => item.Manager.FullName)
</a>
</td>
<!-- …other columns… -->
<td>
<a
href="@Url.Action("Details","JDE", new { id = item.Id })"
target="_blank"
class="btn-sm btn-info">
Details <img src="~/details.png" style="width:20px;" />
</a>
</td>
<td>
<a
href="@Url.Action("Edit","FieldOffices", new { id = item.Id })"
target="_blank"
class="btn-sm btn-warning">
Update <img src="~/update.png" style="width:23px;" />
</a>
</td>
</tr>
}
</tbody>
</table>
7. DataTables Integration 📊
CSS Imports
<link href="~/lib/datatables/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/buttons/1.7.1/css/buttons.dataTables.min.css" rel="stylesheet" />
Script Imports
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>
Initialization
<script>
$(document).ready(function () {
$('#fieldOfficesDatatable').DataTable({
dom: 'Bfrtip',
buttons: [ 'csv', 'excel', 'print' ]
});
});
</script>
8. Third‑party Integrations 🔗
- Bootstrap: Responsive grid & button styles.
- jQuery: Required by DataTables.
- DataTables: Enhanced table features (sorting, paging, export).
- JSZip / PDFMake: Client‑side generation of Excel / PDF.
9. API Endpoints Overview 🔌
| Action | Controller | HTTP Verb | Route | Description |
|---|---|---|---|---|
| Index | JDEController |
GET | /JDE/Index |
Renders this view with model data |
| Create | FieldOfficesController |
GET/POST | /FieldOffices/Create |
Add a new FieldOffice |
| Details | JDEController |
GET | /JDE/Details/{id} |
Show read‑only details |
| Edit | FieldOfficesController |
GET/POST | /FieldOffices/Edit/{id} |
Update an existing record |
| Details | EmployeesController |
GET | /Employees/Details/{id} |
Link to Employee details |
Note: The view uses Tag Helpers (asp-action, asp-controller, asp-route-id) to build correct URLs.
10. Sample Usage 🛠️
Controller Action (C#)
public class JDEController : Controller
{
private readonly ApplicationDbContext _context;
public JDEController(ApplicationDbContext context)
{
_context = context;
}
public async Task<IActionResult> Index()
{
var offices = await _context.FieldOffices
.Include(f => f.Manager)
.Include(f => f.Superintendent)
.Include(f => f.ProjectManager)
.Include(f => f.Lead)
.ToListAsync();
return View(offices);
}
}
Navigation Link (in Layout)
<a class="nav-link" asp-area="" asp-controller="JDE" asp-action="Index">
Field Offices
</a>
11. UML Diagram 🧩
classDiagram
class FieldOffice {
+int Id
+string JdeNumber
+string Name
+string OfficePhone
+string FaxNumber
+string MailingAddress
}
class Employee {
+int Id
+string FullName
}
FieldOffice --> Employee : Manager
FieldOffice --> Employee : Superintendent
FieldOffice --> Employee : ProjectManager
FieldOffice --> Employee : Lead
12. Conclusion 🎯
This Index.cshtml view provides a rich, interactive listing of all Field Offices, complete with:
- Dynamic badge for record count.
- Action buttons for creation, detail view, and updates.
- Advanced client‑side features thanks to DataTables.
By following this pattern, developers can easily extend functionality (filtering, row‑level permissions, inline editing) while preserving a consistent look & feel across the application.
Happy Coding! ✨