đ JobMasterList.cshtml Documentation
⨠Beautiful Markdown Documentation for the Razor View
Location: IrbyImaging/Views/JDE/JobMasterList.cshtml
Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model & Data Models
- Key Functional Areas
- ThirdâParty Integrations
- Usage Example
- UML Diagram
- Conclusion
1. Overview & Purpose
đ What this view does:
- Renders a Job Master List table in an ASP.NET Core MVC application.
- Lists all
Jobentities with related navigation properties (FieldOffice, Employees, Contacts). - Integrates DataTables for clientâside searching, sorting, paging, and export (CSV/Excel/Print).
đ Intended Use:
- Used by the JDE module to display a master list of projects/jobs.
- Provides links to detailed pages for each Job, Field Office, or Employee.
- Part of an internal dashboard for Irby Imaging.
2. Dependencies & Technologies
| Package / Library | Purpose | Version / Source |
|---|---|---|
| Microsoft AspNetCore.Mvc.Razor | Razor view engine | Builtâin |
| jQuery | DOM manipulation | 3.5.1 CDN |
| DataTables | Interactive table (sorting, searching, export) | 1.10.25 (core), 1.7.1 (buttons) |
| Bootstrap 4 | Styling & responsive layout | bootstrap.bundle.min.js, dataTables.bootstrap4.css |
| jszip, pdfmake, vfs_fonts | Clientâside export (Excel via CSV, PDF generation) | CDN for JSZip & PDFMake |
| MetisMenu, SimpleBar, Waves.js | Admin template utilities | Local libs |
3. View Model & Data Models
@model IEnumerable<IrbyImaging.DomainClasses.Job>
DomainClasses.Job
- Guid JobId
- int JdeNumber
- string Name
- string JobType
- string Status
- Guid FieldOfficeId
- FieldOffice FieldOffice
- Guid ManagerId, SuperintendentId
- Employee Manager, Superintendent
DomainClasses.FieldOffice
- Guid FieldOfficeId
- string Name
- Guid? ProjectManagerId, LeadId, DirectorId
- Employee ProjectManager, Lead, Director
- string ShippingAddress, MailingAddress
- string OfficePhone, FaxNumber
- Employee PrimaryContact, SecondaryContact
DomainClasses.Employee
- Guid EmployeeId
- string FullName
4. Key Functional Areas
1. Title & Layout Configuration
@{
ViewData["Title"] = "Job Master List";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<h2>
Job Master List
<span class="badge irby-blue" style="color: #495057;">
@Model.Count()
</span>
</h2>
<br />
- ViewData["Title"] sets the page title for SEO & browser tab.
- Layout references the shared site template (
_ATSLayout.cshtml). - Badge displays the total count of jobs.
2. CSS / Asset Inclusions
<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" />
- DataTables Bootstrap 4 theme for consistent styling.
- Buttons extension CSS for export controls.
3. DataTable Markup & Binding
<table id="jobMasterDatatable"
class="table table-striped table-bordered dt-responsive nowrap cell-border"
width="100%" cellspacing="0">
<thead>
<tr>
<th>Job#</th>
<th>Name</th>
<!-- more headings⌠-->
<th>Secondary Contact</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) { ⌠}
</tbody>
</table>
- ID
jobMasterDatatableused by jQuery to initialize DataTables. - Bootstrap classes (
table-striped,table-bordered) for look & feel. - Responsive and nowrap for horizontal scrolling.
4. Row Rendering & Model Binding
@foreach (var item in Model) {
// Determine optional IDs
var ProjectManagerId = item.FieldOffice?.ProjectManagerId ?? Guid.Empty;
var LeadId = item.FieldOffice?.LeadId ?? Guid.Empty;
var DirectorId = item.FieldOffice?.DirectorId ?? Guid.Empty;
<tr>
<td>@Html.DisplayFor(m => item.JdeNumber)</td>
<td>
<a asp-controller="Jobs"
asp-action="Details"
asp-route-id="@item.JobId">
@Html.DisplayFor(m => item.Name)
</a>
</td>
<!-- âŚmore columns⌠-->
<td>@Html.DisplayFor(m => item.FieldOffice.SecondaryContact.FullName)</td>
</tr>
}
- Nullâsafe checks for optional navigation properties.
Html.DisplayForensures correct formatting and HTML-encoding.asp-controller&asp-actiontag helpers generate links to detail pages.
5. Script Section & DataTable Initialization
@section Scripts{
<!-- jQuery & DataTables -->
<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://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>
<!-- Bootstrap & Admin Template -->
<script src="~/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="~/libs/metismenu/metisMenu.min.js"></script>
<script src="~/libs/simplebar/simplebar.min.js"></script>
<script src="~/libs/node-waves/waves.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#jobMasterDatatable').DataTable({
dom: 'Bfrtip',
buttons: ['csv', 'excel', 'print']
});
});
</script>
}
- Buttons: CSV, Excel, Print.
- DOM Option
'Bfrtip'places Buttons (B), filter (f), table (t), etc.
5. ThirdâParty Integrations
- DataTables (+ Buttons extension)
- jQuery
- Bootstrap 4
- jszip & pdfmake for export functionality
- MetisMenu, SimpleBar, Waves for the ATS admin template
6. Usage Example
// JdeController.cs
public class JdeController : Controller
{
private readonly IJobService _jobService;
public JdeController(IJobService jobService)
{
_jobService = jobService;
}
// GET: /Jde/JobMasterList
public IActionResult JobMasterList()
{
var jobs = _jobService.GetAllJobsWithFieldOfficeAndEmployees();
return View(jobs);
}
}
- Service Layer fetches
IEnumerable<Job>including related data via EF Core. - View binds this collection to the Razor page above.
7. UML Diagram
+---------------------------+
| Job |
|---------------------------|
| - Guid JobId |
| - int JdeNumber |
| - string Name |
| - string JobType, Status |
| - Guid FieldOfficeId |
| + FieldOffice |<>âââ+
| + Employee Manager | |
| + Employee Superintendent | |
+---------------------------+ |
1 | |
| * |
v |
+---------------------------+ |
| FieldOffice | |
|---------------------------| |
| - Guid FieldOfficeId | |
| - string Name | |
| - string ShippingAddress, | |
| MailingAddress, | |
| OfficePhone, FaxNumber | |
| + Employee PrimaryContact | |
| + Employee SecondaryContact| |
| + Employee ProjectManager |<>âââ+
| + Employee Lead |
| + Employee Director |
+---------------------------+
- Aggregation (
<>âââ) indicates optional relationships (ProjectManager, Lead, Director).
8. Conclusion
đŻ JobMasterList.cshtml is a featureârich Razor view for listing jobs in a DataTable-powered grid with export capabilities.
- Pros:
- Interactive filtering, sorting, paging
- Easy export (CSV/Excel/Print)
- Semantic Razor and Tag Helpers for maintainability
- Considerations:
- Ensure related data is eagerâloaded in the controller/service to avoid N+1 queries.
- Potentially refactor long razor markup into partial views for readability.
Happy coding! đ ď¸