šŸ“‹ Employee Details View (Details.cshtml) Documentation


Table of Contents

  1. Introduction
  2. Overview & Purpose
  3. Layout & ViewData
  4. Model & Display Helpers
  5. Employee Details Form
  6. Employee Notes Form
  7. Action Buttons & Navigation
  8. Authorization Comments & Conditional Rendering
  9. Scripts & Third‑Party Assets
  10. Dependencies & Technologies
  11. Domain Model & ViewModel
  12. UML Diagram (Mermaid)
  13. Usage Examples
  14. Extending the View
  15. Conclusion

1. Introduction

Welcome to the comprehensive documentation for the Employee Details Razor view in the IrbyImaging application. This view renders all the pertinent details of an Employee domain object, allows notes to be added, and provides navigation for related actions.


2. Overview & Purpose

Purpose:

  • Display a read‑only summary of an employee’s profile (ID, name, phone, job, status, assets).
  • Provide a form to leave or update notes for the employee.
  • Offer navigation buttons to return to the index or add new safety equipment for that employee.

Key Functional Areas:

  • Display of domain data via @Html.DisplayFor
  • Forms for user input (textarea for notes)
  • Tag Helpers for hyperlink generation to related controllers
  • Conditional logic (commented out) for role‑based content

3. Layout & ViewData

@{
    ViewData["Title"] = "Employee Details";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
  • ViewData["Title"] sets the page title to Employee Details.
  • Layout points to a shared layout file (_ATSLayout.cshtml), ensuring consistent header/footer styling.

4. Model & Display Helpers

@model IrbyImaging.DomainClasses.Employee
  • The view’s model is the Employee domain class.
  • Data is rendered with:
    • @Html.DisplayNameFor(m => m.Property) – renders the friendly label (First Name, Title, etc.).
    • @Html.DisplayFor(m => m.Property) – displays the actual property value.

Tip: Display templates can be customized in /Views/Shared/DisplayTemplates.


5. Employee Details Form

<form>
  <dl class="dl-horizontal">
    <dt>@Html.DisplayNameFor(m => m.JdeNumber)</dt>
    <dd>@Html.DisplayFor(m => m.JdeNumber)</dd>
    <!-- ...other properties... -->
    <dt>@Html.DisplayNameFor(m => m.JobId)</dt>
    <dd>
      <a asp-controller="Jobs"
         asp-action="Details"
         asp-route-id="@Model.JobId">
        @Model.Job.Name (@Model.Job.JdeNumber)
      </a>
    </dd>
    <!-- Assets -->
    <dt>@Html.DisplayNameFor(m => m.Status)</dt>
    <dd>@Html.DisplayFor(m => m.Status)</dd>
    <dt>Assigned Assets</dt>
    <dd>
      @foreach(var asset in Model.NotDisposedAssets) {
        <a asp-controller="@($"{asset.Category}s")"
           asp-action="Details"
           asp-route-id="@asset.Id">
          @asset.Model.Make.Name @asset.Model.Name
        </a><br/>
      }
    </dd>
  </dl>
</form>
  • <dl> (description list) provides semantic pairing of labels (<dt>) & values (<dd>).
  • Job link uses Tag Helpers to navigate to the Jobs controller’s Details action.
  • Assets loop renders only not‑disposed items.

6. Employee Notes Form

<form asp-action="EmployeeNotes" method="post">
  <h2>Leave a Note:</h2>
  <textarea asp-for="EmployeeNotes" class="form-control"></textarea>
  <input type="hidden" name="employeeId" value="@Model.EmployeeId" />
  <input type="submit" value="Update Note" class="btn btn-primary" />
</form>
  • Submits to EmployeesController.EmployeeNotes(int employeeId, string employeeNotes).
  • Uses Tag Helper asp-action="EmployeeNotes" to bind route.
  • A hidden field carries the EmployeeId back to the controller.

7. Action Buttons & Navigation

<a asp-action="Index" class="btn btn-danger irby-red">Index List</a>
<a asp-controller="SafetyEquipments"
   asp-action="Create"
   asp-route-OwnerId="@Model.EmployeeId"
   class="btn btn-success irby-green">
  Add New Equipment
</a>
  • Index List returns to the employees list.
  • Add New Equipment opens the SafetyEquipments/Create?OwnerId={EmployeeId} route, auto‑populating the equipment owner.

8. Authorization Comments & Conditional Rendering

šŸ¤” Commented-out code shows an example of how you might conditionally render additional data (like total assets count) only for users in the Admin role.

@* Uncomment to require ā€œAdminPolicyā€ *@
@* if ((await AuthorizationService.AuthorizeAsync(User, "AdminPolicy")).Succeeded) {
     <dt>Total Assets</dt>
     <dd>@Model.Assets.Count</dd>
   }
*@

9. Scripts & Third‑Party Assets

At the bottom of the view:

<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>
  • Bootstrap: UI styling & components.
  • MetisMenu: Side‑menu plugin.
  • SimpleBar, Waves: custom scrollbar & ripple‑effect support.

Note: An AJAX snippet to post notes is commented out—can be enabled for in‑page updates.


10. Dependencies & Technologies

Category Technology / Library
ASP.NET Core MVC Razor Views, Tag Helpers
Styling & Layout Bootstrap 4+, Custom CSS
JavaScript Helpers jQuery (for AJAX, commented), MetisMenu, SimpleBar, Waves
Authorization IAuthorizationService (AdminPolicy)
Domain Model IrbyImaging.DomainClasses.Employee

11. Domain Model & ViewModel

Employee (simplified)

Property Type Description
EmployeeId int Primary key
JdeNumber string JDE system employee ID
FirstName, MiddleName, LastName string Personal name fields
PhoneNumberFromActiveDirectory string AD phone
PhoneNumberFromAssignedMobile string Assigned device phone
Title string Job title
JobId int Foreign key to Job
Job Job Navigation property
Status EmployeeStatus enum Active / Inactive / On Leave
Assets ICollection<Asset> All assigned assets
NotDisposedAssets IEnumerable<Asset> Filtered subset of Assets
EmployeeNotes string Editable notes field

12. UML Diagram (Mermaid)

classDiagram
  class Employee {
    +int EmployeeId
    +string JdeNumber
    +string FirstName
    +string MiddleName
    +string LastName
    +string PhoneFromAD
    +string PhoneFromMobile
    +string Title
    +int JobId
    +EmployeeStatus Status
    +string EmployeeNotes
  }
  class Job {
    +int Id
    +string Name
    +string JdeNumber
  }
  class Asset {
    +int Id
    +string Category
    +ModelDetail Model
    +bool IsDisposed
  }
  Employee --> Job : has a
  Employee "1" o-- "*" Asset : NotDisposedAssets

13. Usage Examples

  1. Navigate to /Employees/Details/5 in your browser.
  2. The controller loads Employee #5, passes it to this view.
  3. Read-only fields appear in a horizontal list.
  4. Leave a note, click Update Note → posts back to EmployeeNotes action.
  5. Use Add New Equipment to jump to the SafetyEquipments/Create form pre‑populated with the employee as owner.

14. Extending the View

  • Enable AJAX notes update: Uncomment the jQuery script & hook up a partial refresh.
  • Role‑based sections: Use @inject IAuthorizationService to show/hide admin‑only data.
  • Styling tweaks: Create a custom DisplayTemplate for dates or phone numbers in /Views/Shared/DisplayTemplates.

15. Conclusion

This Employee Details view is a core piece of the IrbyImaging HR portal, combining read‑only data displays, user input forms, and rich navigation via ASP.NET Core Tag Helpers. By understanding its structure, dependencies, and domain relationships, you can easily maintain, extend, or re‑use it across related features. If you need advanced behaviors (AJAX saves, in‑view editing, role‑based sections), the commented examples provide a solid starting point. šŸš€


Happy coding! šŸ› ļø