πŸ“‹ Employee Directory View Documentation

File: IrbyImaging/Views/JDE/EmployeeDirectory.cshtml


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Models & Data Models
  5. Helper Logic & Utilities
  6. Error Handling & Edge Cases
  7. Third-party Integrations
  8. UML Class Diagram
  9. Sample Code Snippets
  10. Usage Example
  11. Conclusion

1. Overview & Purpose

This Razor view presents the Employee Master List in a tabular format. It displays key employee detailsβ€”such as JDE number, name, title, department, supervisor, mobile numbers, office phone, email, and related job link. The table leverages the DataTables jQuery plugin for sorting, searching, pagination, and exporting (CSV/Excel/Print).

πŸš€ Intended Use:

  • As part of the JDE (JD Edwards) integration module in the IrbyImaging application.
  • Provides HR or administrative staff with a quick, interactive directory of all employees.

2. Key Functional Areas

2.1 ViewModel Binding

@model IEnumerable<IrbyImaging.DomainClasses.Employee>
@inject IrbyContext _context
  • Model: A collection of Employee domain objects.
  • Dependency Injection: IrbyContext for retrieving additional related data (mobile devices).

2.2 Layout & Title Setup

@{
    ViewData["Title"] = "Employee Master List";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<h2>
    Employee Master List 
    <span class="badge irby-blue">@Model.Count()</span>
</h2>
  • Layout: Inherits from a shared layout _ATSLayout.
  • Page Title & Badge: Displays the total count of employees dynamically.

2.3 HTML Markup & Data Rendering

Section Description
<table> Defines the main grid with columns & data.
<thead> Static column headers.
<tbody> Dynamically generated rows using a foreach loop.
Mobile Phone Retrieval Queries _context.MobileDevices to get primary & secondary numbers from assets.
@foreach (var item in Model) {
    // Determine primary and secondary mobile numbers
    var assets = item.Assets
        .Where(a => a.Category == Utility.AssetCategory.MobileDevice)
        .ToList();
    // ...
    <tr>
        <td>@item.JdeNumber</td>
        <td>@item.FullName</td>
        <td>@item.Title</td>
        <td>@item.Department.Name</td>
        <td>
            <a asp-controller="Employees" asp-action="Details" asp-route-id="@item.ManagerId">
                @item.ManagerName
            </a>
        </td>
        <td>
            <a asp-controller="Jobs" asp-action="Details" asp-route-id="@item.JobId">
                @item.Job.Name
            </a>
        </td>
        <td>@primary</td>
        <td>@secondary</td>
        <td>@item.OfficePhone</td>
        <td>@item.WorkEmail</td>
    </tr>
}

2.4 DataTables Integration

  • CSS: Loaded from local & CDN for styling.
  • JS: Includes jQuery, DataTables core, Buttons extension, export libraries (JSZip, pdfmake).
  • Initialization Script:
    $(document).ready(function () {
        $('#empMasterDatatable').DataTable({
            dom: 'Bfrtip',
            buttons: ['csv', 'excel', 'print']
        });
    });
    

3. Dependencies & Technologies

Technology Purpose
ASP.NET Core Razor Views Server-rendered HTML with C# integration.
Entity Framework Core Database context (IrbyContext) & models.
DataTables (jQuery plugin) Interactive table (search, sort, export).
Bootstrap 4 Responsive table styling.
jQuery DOM manipulation & plugin initialization.

4. View Models & Data Models

Primary Model: IEnumerable<DomainClasses.Employee>

  • Employee
    • int JdeNumber
    • string FullName
    • string Title
    • Department Department
    • int ManagerId, string ManagerName
    • Job Job
    • string OfficePhone, string WorkEmail
    • ICollection<Asset> Assets

Related Models:

  • Department (Name)
  • Job (Name)
  • Asset (Category, Id)
  • MobileDevice (Id, PhoneNumber)

5. Helper Logic & Utilities

  • Mobile Phone Extraction:
    var assets = item.Assets
        .Where(a => a.Category == AssetCategory.MobileDevice)
        .ToList();
    if (assets.Any()) { ... }
    
  • Razor Tag Helpers:
    • asp-controller, asp-action, asp-route-id for generating proper links.

6. Error Handling & Edge Cases

  • No Assets: If an employee has no mobile-device assets, both primary and secondary cells render empty strings.
  • Single Asset: Only primary is populated.
  • Multiple Assets: First asset β†’ primary, next distinct asset β†’ secondary.

7. Third-party Integrations

  • DataTables Export Buttons:
    • CSV (buttons.csv)
    • Excel (buttons.excel)
    • Print (buttons.print)
  • JSZip & pdfmake: Required for Excel and PDF export functionalities.

8. UML Class Diagram

classDiagram
    class Employee {
        +int JdeNumber
        +string FullName
        +string Title
        +string OfficePhone
        +string WorkEmail
        +int ManagerId
        +string ManagerName
    }
    class Department {
        +string Name
    }
    class Job {
        +string Name
    }
    class Asset {
        +int Id
        +AssetCategory Category
    }
    class MobileDevice {
        +int Id
        +string PhoneNumber
    }

    Employee --> Department
    Employee --> Job
    Employee "1" o-- "*" Asset
    Asset --> MobileDevice : resolves to

9. Sample Code Snippets

Razor View Declaration

@model IEnumerable<IrbyImaging.DomainClasses.Employee>
@inject IrbyContext _context

DataTables Initialization

<script>
$(function() {
  $('#empMasterDatatable').DataTable({
    dom: 'Bfrtip',
    buttons: ['csv', 'excel', 'print']
  });
});
</script>

10. Usage Example

  1. Controller Action
    public async Task<IActionResult> EmployeeDirectory() {
        var employees = await _context.Employees
            .Include(e => e.Department)
            .Include(e => e.Job)
            .Include(e => e.Assets)
            .ToListAsync();
        return View(employees);
    }
    
  2. Navigate: /JDE/EmployeeDirectory
  3. Interact: Sort columns, search by name, export to Excel/CSV, print.

11. Conclusion

This view is a central hub for displaying and interacting with the company’s employee data. Leveraging Razor’s seamless C# integration, Entity Framework for data access, and jQuery DataTables for a rich UI experience, it provides administrators with a powerful, export-capable directory.

πŸŽ‰ Enjoy the simplicity of ASP.NET Razor coupled with the flexibility of DataTables for a top-notch user experience!