š Employee Details View (Details.cshtml) Documentation
Table of Contents
- Introduction
- Overview & Purpose
- Layout & ViewData
- Model & Display Helpers
- Employee Details Form
- Employee Notes Form
- Action Buttons & Navigation
- Authorization Comments & Conditional Rendering
- Scripts & ThirdāParty Assets
- Dependencies & Technologies
- Domain Model & ViewModel
- UML Diagram (Mermaid)
- Usage Examples
- Extending the View
- 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 (
textareafor 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.Layoutpoints 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
Employeedomain 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
- Navigate to
/Employees/Details/5in your browser. - The controller loads
Employee#5, passes it to this view. - Read-only fields appear in a horizontal list.
- Leave a note, click Update Note ā posts back to
EmployeeNotesaction. - Use Add New Equipment to jump to the
SafetyEquipments/Createform 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 IAuthorizationServiceto 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! š ļø