📄 IrbyImaging/Views/Jobs/Details.cshtml Documentation

Path: IrbyImaging/Views/Jobs/Details.cshtml
Purpose: Renders the Job Details page, showing core job data, associated employees, and assigned assets.


📑 Table of Contents

  1. Overview & Purpose
  2. File Structure & Layout
  3. Dependencies & Technologies
  4. View Model & Data Model
  5. Key Functional Areas
  6. Sample Controller Usage
  7. UML Class Diagram (Simplified)
  8. Conclusion

🔍 Overview & Purpose

This Razor view displays details for a single Job record within the Irby Imaging application. It:

  • Shows Job metadata (JdeNumber, Name).
  • Lists Active and Terminated employees associated with the job.
  • Enumerates Assets assigned to the job (e.g., equipment).
  • Provides navigation back to the job index.

Intended Use: Invoked by the JobsController.Details(int id) action.


🏗️ File Structure & Layout

IrbyImaging/
└── Views/
    └── Jobs/
        └── Details.cshtml      ← This file
  • Layout: Uses the shared layout _ATSLayout.cshtml.
  • Title: Sets ViewData["Title"] = "Job Details" for page metadata.
@model IrbyImaging.DomainClasses.Job
@{
    ViewData["Title"] = "Job Details";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}

📦 Dependencies & Technologies

Technology / Library Purpose
ASP.NET Core Razor Pages Server‑side rendering with C# and .cshtml files
Tag Helpers (asp-*) Declarative URL generation for MVC actions
HTML Helpers (Html.*) Display metadata & values from the strongly typed model
Bootstrap 5 Styling & components (btn, dl-horizontal)
MetisMenu, SimpleBar, Waves Enhanced sidebar, scrolling & ripple effects
<!-- Scripts loaded at bottom for performance -->
<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>

🔗 View Model & Data Model

Model: IrbyImaging.DomainClasses.Job
A simplified view of the domain class:

Property Type Description
JdeNumber string Unique job identifier
Name string Human‑readable job name
... … Additional fields (dates, status, etc.)

ViewBag

  • CurrentEmployees: IEnumerable<Employee> (Active)
  • FormerEmployees: IEnumerable<Employee> (Terminated)
  • Assets: IEnumerable<Asset> (Assigned to job)

Employee has properties EmployeeId, FullName.
Asset has Id, Category, and navigational Model.Make.Name & Model.Name.


⚙️ Key Functional Areas

5.1 Display Basic Job Properties

<dl class="dl-horizontal">
  <dt>@Html.DisplayNameFor(m => m.JdeNumber)</dt>
  <dd>@Html.DisplayFor(m => m.JdeNumber)</dd>

  <dt>@Html.DisplayNameFor(m => m.Name)</dt>
  <dd>@Html.DisplayFor(m => m.Name)</dd>
</dl>
  • DisplayNameFor: Renders the friendly label from model metadata.
  • DisplayFor: Renders the actual property value.

5.2 List Active Employees

<dt>Active Employees</dt>
<dd>
  @foreach (var emp in ViewBag.CurrentEmployees) {
    <a asp-controller="Employees"
       asp-action="Details"
       asp-route-id="@emp.EmployeeId">
      @emp.FullName
    </a><br />
  }
</dd>
  • Loop through ViewBag.CurrentEmployees.
  • Tag Helpers generate links to Employees/Details/{id}.

5.3 List Terminated Employees

<dt>Terminated Employees</dt>
<dd>
  @foreach (var emp in ViewBag.FormerEmployees) {
    <a asp-controller="Employees"
       asp-action="Details"
       asp-route-id="@emp.EmployeeId">
      @emp.FullName
    </a><br />
  }
</dd>
  • Mirrors the active list but for former staff.

5.4 List Assigned Assets

<dt>@ViewBag.AssetCount Assigned Asset(s)</dt>
<dd>
  @foreach (var asset in ViewBag.Assets) {
    <a asp-controller="@($"{asset.Category}s")"
       asp-action="Details"
       asp-route-id="@asset.Id">
      @asset.Model.Make.Name @asset.Model.Name
    </a><br />
  }
</dd>
  • Dynamically builds controller name based on asset.Category (e.g., "Laptop" → LaptopsController).
  • Commented authorization scaffolding hints at showing this only to admins.

5.5 Navigation & Buttons

<div>
  <a asp-action="Index" class="btn btn-danger irby-red">← Back to Index</a>
</div>
  • Redefined Bootstrap button with corporate color (irby-red).
  • Returns user to the job listing page.

5.6 Client‑Side Scripts

At the bottom of the page to optimize loading:

Script Use Case
bootstrap.bundle.min.js Components & responsive behavior
metisMenu.min.js Sidebar menu interactions
simplebar.min.js Custom scrollbars
waves.min.js Ripple effects on clickable elements

🛠️ Sample Controller Usage

public class JobsController : Controller {
    private readonly IJobService _jobService;
    private readonly IEmployeeService _employeeService;
    private readonly IAssetService _assetService;

    public async Task<IActionResult> Details(int id) {
        var job = await _jobService.GetByIdAsync(id);
        if (job == null) return NotFound();

        ViewBag.CurrentEmployees = 
            await _employeeService.GetByJobAsync(id, onlyActive: true);

        ViewBag.FormerEmployees =
            await _employeeService.GetByJobAsync(id, onlyActive: false);

        var assets = await _assetService.GetByJobAsync(id);
        ViewBag.AssetCount = assets.Count();
        ViewBag.Assets = assets;

        return View(job);
    }
}
  1. Fetch the Job domain object.
  2. Retrieve related employees & assets.
  3. Populate ViewBag.
  4. Return the strongly‑typed view.

🧩 UML Class Diagram (Simplified)

+----------------------+
|   DomainClasses.Job  |
+----------------------+
| - JdeNumber : string |
| - Name      : string |
+----------------------+
           |
           | 1..* on JobId
           v
+------------------------+
|     Employee           |
+------------------------+
| - EmployeeId : int     |
| - FullName   : string  |
+------------------------+

           |
           | 1..* on JobId
           v
+------------------------+
|      Asset             |
+------------------------+
| - Id       : int       |
| - Category : string    |
| - Model             \ |
|   + Name             \|
|   + Make.Name         |
+------------------------+

🏁 Conclusion

The Details.cshtml view is a core component in the Jobs feature of Irby Imaging, providing a user-friendly presentation of:

  • Core job identifiers and names
  • Active vs. terminated workforce
  • Equipment/assets assigned to the job

By leveraging ASP.NET Core Razor conventions, Tag Helpers, and ViewBag, it cleanly separates concerns:

  • Controllers handle data retrieval & authorization
  • Views focus on rendering and layout

This modular approach ensures maintainability, easy theming via the shared layout (_ATSLayout.cshtml), and straightforward extension for features like role‑based asset visibility or additional job metadata.


🚀 Next Steps & Tips

  • Enable Authorization: Un-comment and configure the AuthorizationService checks around assets for admin-only visibility.
  • Enhance Styling: Use additional Bootstrap or custom CSS classes for better spacing and mobile responsiveness.
  • Add Partial Views: If the asset list grows complex, refactor it into a partial (e.g., _JobAssets.cshtml).
  • Unit Test: Write MVC tests for the JobsController.Details to validate ViewBag contents and proper view selection.

Enjoy building and extending the Job Details page! 🎉