📄 JDEController Documentation
Welcome to the JDEController documentation! This guide provides an in-depth overview of the /Controllers/JDEController.cs file in the IrbyImaging application. You will find:
- A comprehensive Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- API Endpoints Reference
- View & Data Models
- Helper Methods & Utilities
- Error Handling & Return Types
- Third‑Party Integrations
- Sample Code Blocks & Usage Examples
- UML Diagram
- Conclusion
Let’s dive in! 🚀
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- API Endpoints Overview
- View Models & Data Models
- Helper Methods & Utilities
- Error Handling & Return Types
- Third‑Party Integrations
- Sample Code Blocks & Usage Examples
- UML Diagram
- Conclusion
1. Overview & Purpose
The JDEController is an ASP.NET Core MVC controller within the IrbyImaging.Controllers namespace. Its primary responsibilities are:
- Managing Field Offices (CRUD)
- Displaying Job, Employee, Asset, Work Order, and Purchase Order directories
- Providing search & filter capabilities
- Rendering a Field Office Map with aggregated data
This controller leverages business logic via the IEmployeeAndFieldOfficeManager service and interacts with the IrbyContext (Entity Framework Core) to fetch and manipulate data.
2. Dependencies & Technologies
| Package / Namespace | Purpose |
|---|---|
Microsoft.AspNetCore.Mvc |
MVC framework, controllers & views |
Microsoft.EntityFrameworkCore |
ORM for database access |
Microsoft.Extensions.Configuration |
Configuration settings |
IrbyImaging.BusinessLogic |
Business services (IEmployeeAndFieldOfficeManager) |
IrbyImaging.Models |
EF Core data models |
IrbyImaging.Services |
Additional application services |
IrbyImaging.Utility |
Utility enums & helpers |
Syncfusion.PMML, Org.BouncyCastle.Ocsp |
(Referenced but not directly used) |
NuGet.*, Microsoft.Graph.Models.Security |
(Referenced but not directly used) |
3. Key Functional Areas
- Field Office Management
- List, create, edit, and view details of field offices.
- Job Management
- Display field‑office-specific jobs and a global job master list.
- Directories & Mappings
- Employee Directory
- Equipment Directory
- Work Order & Purchase Order Directory
- Field Office Map (geospatial & aggregated stats)
- Search & Filters
- Custom search parameters for jobs, work orders, equipment, etc.
4. API Endpoints Overview
Below is a summary of the controller’s public actions (endpoints). All endpoints return IActionResult or its derivatives.
4.1 Field Office
| Method | Route | Description |
|---|---|---|
| GET | /JDE/Index?search={string} |
List field offices (optional search filter) |
| GET | /JDE/Details/{id} |
View details of a specific field office |
| GET | /JDE/Create |
Show create field office form |
| POST | /JDE/Create |
Persist new field office |
| GET | /JDE/Edit/{id} |
Show edit form for a field office |
| POST | /JDE/Edit |
Update field office |
4.2 Jobs
| Method | Route | Description |
|---|---|---|
| GET | /JDE/JobMasterList |
Show all active (non‑closed) jobs |
4.3 Mappings & Directories
| Method | Route | Description |
|---|---|---|
| GET | /JDE/FieldOfficeMap?search={string}&embed={bool} |
Display map of field offices with stats |
| GET | /JDE/EmployeeDirectory |
List all active employees |
| GET | /JDE/WorkOrderDirectory |
List open work orders |
| POST | /JDE/SearchWO |
Search work orders via form parameters |
| GET | /JDE/PurchaseOrderDirectory |
List all purchase orders |
| GET | /JDE/GetTypes?clsName={string} |
AJAX: retrieve equipment types by class name |
| GET | /JDE/EquipmentDirectory |
Show equipment directory with filters |
| POST | /JDE/Search |
Filter equipment directory based on form input |
5. View Models & Data Models
Three inner classes are used to shape data for views:
5.1 AssetDetail
public class AssetDetail {
public Guid Id { get; set; }
public string Category { get; set; }
public string Make { get; set; }
public string Model { get; set; }
public string SerialNumber { get; set; }
public Guid EmployeeId { get; set; }
public string OwnerFullName { get; set; }
public string Status { get; set; }
}
5.2 EmpDetail
public class EmpDetail {
public Guid EmployeeId { get; set; }
public string JdeNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string MiddleName { get; set; }
public Guid JobId { get; set; }
public string JobName { get; set; }
public string EmployeeStatus { get; set; }
}
5.3 JobDetails
public class JobDetails {
public Guid JobId { get; set; }
public string JdeNumber { get; set; }
public string Name { get; set; }
// ... other job & contact fields ...
public string JobStatus { get; set; }
// FieldOffice address & contact fields
public string MailingAddress { get; set; }
// ...
}
6. Helper Methods & Utilities
FieldOfficeExists
A private check to avoid concurrency exceptions:
private bool FieldOfficeExists(Guid id) {
return _context.FieldOffices.Any(e => e.Id == id);
}
7. Error Handling & Return Types
- 404 NotFound if required
idisnullor entity not found. - ModelState validation on POST actions (
Create&Edit). - DbUpdateConcurrencyException in
Edit: rethrows if the field office was deleted by another process.
All actions return one of:
View(...)RedirectToAction(...)PartialView()Json(...)NotFound()
8. Third‑Party Integrations
While several packages are referenced (e.g., Syncfusion.PMML, BouncyCastle.Ocsp, Microsoft.Graph.Models.Security), this controller does not directly consume them. Check other parts of the solution for PMML scoring, OCSP certificate checks, or Microsoft Graph security integrations.
9. Sample Code Blocks & Usage Examples
9.1 Calling the FieldOfficeMap via AJAX
fetch('/JDE/FieldOfficeMap?search=North&embed=true')
.then(res => res.text())
.then(html => {
document.getElementById('mapContainer').innerHTML = html;
});
9.2 Razor View: Equipment Dropdowns
@model IrbyImaging.UI.Models.Equipment
<form asp-action="Search">
<select asp-for="Class" asp-items="Model.EquipmentClasses"></select>
<select asp-for="Type" asp-items="Model.EquipmentTypes"></select>
<input type="text" asp-for="SerialNumber" placeholder="Serial #" />
<button type="submit">🔍 Search</button>
</form>
<div>
@foreach(var item in (IEnumerable<Equipment>)ViewBag.Equipment) {
<p>@item.UnitTagNumber – @item.Job.JdeNumber</p>
}
</div>
10. UML Diagram
Below is a simplified Class Diagram focusing on relationships in JDEController:
+-------------------+
| BaseController |<------------------------------------+
+-------------------+ |
| - _context | |
| - _configuration | |
+-------------------+ |
^ |
| inherits uses
+-------------------+ +----------------------+ |
| JDEController |-------->| IEmployeeAndField... |---+
+-------------------+ +----------------------+
| +Index(...) |
| +Details(...) |
| +JobMasterList() |
| +... |
+-------------------+
11. Conclusion 🎉
The JDEController is the central hub for:
- Field Office lifecycle management
- Job, Employee, Equipment, Work Order, and Purchase Order directories
- Interactive Map of field offices
- Rich search & filter experiences
Use the methods above to integrate with Razor views, AJAX calls, or unit tests. Extend the controller by injecting additional services or adding new endpoints as business needs evolve. Happy coding! 🛠️
End of JDEController.md