📄 JobMasterList.cshtml Documentation


📑 Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Models & Domain Classes
  5. Markup & Structure
  6. Scripts & Assets
  7. Detailed Code Walkthrough
  8. API Endpoints Overview 🔗
  9. Usage Example & Integration 🚀
  10. UML Class Diagram 🎯
  11. Conclusion & Best Practices ✅

1. Overview & Purpose

JobMasterList.cshtml is an ASP.NET Core Razor View located in:

/Views/FieldOffices/JobMasterList.cshtml

It renders a master list of all Jobs across Field Offices in a fully-featured, exportable DataTable.

Key goals

  • Display comprehensive job data alongside related Field Office and Employee info
  • Provide sorting, searching & export (CSV, Excel, Print) via DataTables
  • Leverage ASP.NET Core MVC tag‑helpers for clickable links to detail pages

2. Key Functional Areas

Area Description
Title & Layout Setup Sets ViewData Title and uses shared _ATSLayout master layout
Data Presentation Loops through IEnumerable<Job> and binds to HTML table rows
Tag‑Helpers & Linking Uses asp-controller, asp-action, asp-route-id for navigation
DataTables Integration Imports CSS/JS and initializes DataTable with Buttons extension
Null‑Safety Logic Computes nullable ProjectManagerId, LeadId, DirectorId to prevent errors

3. Dependencies & Technologies

  • ASP.NET Core MVC & Razor view engine
  • jQuery 3.5.1
  • DataTables 1.10.25 + Buttons 1.7.1 extension
  • JSZip, pdfmake (for Excel/PDF export)
  • Bootstrap 4 (styles & responsive layout)
  • MetisMenu, Simplebar, Node‑Waves (UI enhancements in _ATSLayout)

4. View Models & Domain Classes

4.1 Job (Model)

Property Type Description
JobId Guid Primary key
JdeNumber int Internal job number
Name string Job title
JobType enum Type/category of the job
Status enum Current job status
FieldOfficeId Guid FK to FieldOffice
FieldOffice FieldOffice Navigation property
ManagerId Guid FK to Employee (Manager)
Manager Employee Navigation property
SuperintendentId Guid FK to Employee (Superintendent)
Superintendent Employee Navigation property

4.2 FieldOffice (Nested)

Property Type Description
FieldOfficeId Guid PK
Name string Office name
ProjectManagerId Guid? Nullable FK
ProjectManager Employee Navigation property
LeadId Guid? Nullable FK
Lead Employee Navigation property
DirectorId Guid? Nullable FK
Director Employee Navigation property
ShippingAddress string Street address
MailingAddress string PO Box or mailing address
OfficePhone string Main phone
FaxNumber string Fax number
PrimaryContact Employee Navigation property
SecondaryContact Employee Navigation property

4.3 Employee (Nested)

Property Type Description
EmployeeId Guid PK
FullName string e.g. "Jane Doe"

5. Markup & Structure

@model IEnumerable<IrbyImaging.DomainClasses.Job>

@{
  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 />

<!-- DataTables CSS -->
<link href="~/lib/datatables/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
...
<table id="jobMasterDatatable" class="table table-striped table-bordered dt-responsive nowrap" width="100%">
  <thead> ... </thead>
  <tbody>
    @foreach(var item in Model) {
      <!-- Compute nullable IDs -->
      <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 <td> columns... -->
      </tr>
    }
  </tbody>
</table>
  • @model directive: expects IEnumerable<Job>
  • ViewData["Title"] & Layout: configures page title & master layout
  • <table>: ID = jobMasterDatatable triggers DataTables
  • asp-controller, asp-action, asp-route-id: build dynamic links

6. Scripts & Assets

File / CDN URL Purpose
~/lib/datatables/js/jquery.dataTables.min.js Core DataTables
https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js Buttons extension
https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js Excel export
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js PDF export
https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js HTML5 export
https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js Print button
~/libs/bootstrap/js/bootstrap.bundle.min.js Bootstrap JS
~/libs/metismenu/metisMenu.min.js Side‑menu plugin
~/libs/simplebar/simplebar.min.js Custom scrollbars
~/libs/node-waves/waves.min.js Ripple effect

Initialization Script

$(document).ready(function () {
  $('#jobMasterDatatable').DataTable({
    dom: 'Bfrtip',
    buttons: ['csv', 'excel', 'print']
  });
});

7. Detailed Code Walkthrough

  1. Null‑Safety Pre‑processing

    var ProjectManagerId = Guid.Empty;
    if (item.FieldOffice?.ProjectManagerId.HasValue == true)
      ProjectManagerId = item.FieldOffice.ProjectManagerId.Value;
    // Similarly for LeadId, DirectorId
    
  2. Row Generation
    Each <tr> has 16 <td> columns mapping exactly to:

    1. Job#
    2. Name (linked)
    3. Type
    4. Status
    5. Field Office (linked)
    6. Manager (linked)
    7. Superintendent (linked)
    8. Project Manager (linked)
    9. Lead (linked)
    10. Director (linked)
    11. Shipping Address
    12. Mailing Address
    13. Office Phone
    14. Fax Number
    15. Primary Contact (name)
    16. Secondary Contact (name)
  3. Razor Helpers

    • @Html.DisplayFor(...) for safe display & formatting
    • <a asp-*> for MVC routing & URL generation

8. API Endpoints Overview 🔗

Although this is purely a View, it links to several controller actions:

Section Controller Action Route Parameter
Job Name Link JobsController Details id = item.JobId
Field Office Link FieldOfficesController Details id = item.FieldOfficeId
Employee Links EmployeesController Details id = [ManagerId, SuperintendentId, ProjectManagerId, LeadId, DirectorId]

These links allow drilling into details for each entity.


9. Usage Example & Integration 🚀

  1. Controller (FieldOfficesController.cs)
    public async Task<IActionResult> JobMasterList()
    {
      // Fetch all jobs with related FieldOffice & Employee nav props
      var jobs = await _jobService.GetAllJobsWithRelationsAsync();
      return View(jobs);
    }
    
  2. Route
    endpoints.MapControllerRoute(
      name: "default",
      pattern: "{controller=FieldOffices}/{action=JobMasterList}/{id?}");
    
  3. Invoke in Browser
    Navigate to:
    https://yourapp.com/FieldOffices/JobMasterList
    
  4. User Interactions
    • 🔍 Search/filter
    • 🔀 Sort columns
    • 📥 Export CSV / Excel / Print

10. UML Class Diagram 🎯

classDiagram
  class Job {
    +Guid JobId
    +int JdeNumber
    +string Name
    +JobType JobType
    +JobStatus Status
    +Guid FieldOfficeId
  }
  class FieldOffice {
    +Guid FieldOfficeId
    +string Name
    +Guid? ProjectManagerId
    +Guid? LeadId
    +Guid? DirectorId
    +string ShippingAddress
    +string MailingAddress
    +string OfficePhone
    +string FaxNumber
  }
  class Employee {
    +Guid EmployeeId
    +string FullName
  }

  Job "1" --> "1" FieldOffice : FieldOffice
  Job "1" --> "1" Employee : Manager
  Job "1" --> "1" Employee : Superintendent
  FieldOffice "1" --> "0..1" Employee : ProjectManager
  FieldOffice "1" --> "0..1" Employee : Lead
  FieldOffice "1" --> "0..1" Employee : Director
  FieldOffice "1" --> "1" Employee : PrimaryContact
  FieldOffice "1" --> "1" Employee : SecondaryContact

11. Conclusion & Best Practices ✅

  • Maintain Navigation Props: Ensure FieldOffice, Manager, Superintendent, etc., are eagerly loaded to avoid N+1 queries.
  • Null Checks: Pre‑compute nullable IDs to prevent runtime exceptions.
  • Performance: For large datasets, consider server‑side processing with DataTables.
  • Styling: Leverage the shared _ATSLayout for consistent branding and UI.
  • Accessibility: Add ARIA labels and proper <thead><tbody> semantics for screen readers.

🚀 This view provides a powerful, user-friendly interface for managing and exporting the company’s job inventory across all field offices.


Generated on: {{Date}}
IrbyImaging Application – Field Offices Module