📋 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Razor View Structure
- Data Model: DeskPhoneDetailViewModel
- Key Functional Areas
- Controller Endpoints Overview
- Third‑Party Integrations
- UML Diagram
- Sample Usage Scenario
- Conclusion
🔍 Overview & Purpose
This Razor view (Details.cshtml) presents a read-only detail page for a single desk phone asset in the IrbyImaging application. It renders properties such as serial number, MAC address, owner, and purchase date, and provides navigation options to Index, Edit, and History actions.
- Location:
Views/DeskPhones/Details.cshtml - Model:
DeskPhoneDetailViewModel - Layout:
~/Views/Shared/_ATSLayout.cshtml
🧰 Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| ASP.NET Core MVC Razor | Templating engine for server‑side HTML rendering. |
| Bootstrap (v5) | UI layout & responsive design. |
| MetisMenu | Collapsible sidebar menu. |
| SimpleBar | Custom scrollbars. |
| Waves.js (node-waves) | Click effect on buttons/links. |
🔨 Razor View Structure
@model DeskPhoneDetailViewModel
@{
ViewData["Title"] = "DeskPhone Details";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
// Header with Make & Model plus Status badge
<h2>
@Html.DisplayFor(m => m.MakeAndModel)
<span class="badge @Model.StatusColor" style="color:blue">@Model.Status</span>
</h2>
// Details definition list
<div>
<h4>Asset ID: @Model.Id</h4>
<hr />
<dl class="dl-horizontal">
<!-- Serial Number -->
<dt>@Html.DisplayNameFor(m => m.SerialNumber)</dt>
<dd>@Html.DisplayFor(m => m.SerialNumber)</dd>
<!-- ... other fields ... -->
<dt>@Html.DisplayNameFor(m => m.Notes)</dt>
<dd><pre>@Model.Notes</pre></dd>
</dl>
</div>
// Action buttons row
<div>
<a asp-action="Index" class="btn btn-danger irby-red">Index List</a>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-warning irby-orange">Update</a>
<a asp-action="History" asp-route-id="@Model.Id" class="btn btn-primary irby-violet">History</a>
</div>
// Scripts for UI enhancements
<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>
📦 Data Model: DeskPhoneDetailViewModel
This view expects a strongly‑typed model carrying all desk phone details.
| Property | Type | Description |
|---|---|---|
| MakeAndModel | string | Combined make & model (e.g., “Polycom VVX 411”). |
| Status | string | Current status label (e.g., “Active”). |
| StatusColor | string | CSS class for badge background (e.g., “bg-success”). |
| Id | int | Unique asset identifier. |
| SerialNumber | string | Manufacturer’s serial number. |
| PhoneNumber | string | Assigned phone extension. |
| MacAddress | string | Network MAC address. |
| PurchaseDate | DateTime | Date when the phone was purchased. |
| OwnerFullName | string | Full name of the employee assigned to it. |
| OwnerId | int | FK to Employees controller for details page. |
| Notes | string | Free‑text notes or comments. |
🏷️ Key Functional Areas
1. Title & Layout Configuration
@{
ViewData["Title"] = "DeskPhone Details";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
- ViewData["Title"] sets the browser’s title bar.
- Layout points to a common shell (
_ATSLayout.cshtml) for navigation, header and footer.
2. Display Fields (Details List)
<dl class="dl-horizontal">
<dt>@Html.DisplayNameFor(m => m.SerialNumber)</dt>
<dd>@Html.DisplayFor(m => m.SerialNumber)</dd>
<!-- … other dt/dd pairs … -->
</dl>
- Uses
<dl>(definition list) for semantic pairing of labels (<dt>) and values (<dd>). DisplayNameForauto‑generates a label from metadata or property name.DisplayForsafely HTML‑encodes and renders the property value.
3. Owner Link
<dt>@Html.DisplayNameFor(m => m.OwnerFullName)</dt>
<dd>
<a asp-controller="Employees"
asp-action="Details"
asp-route-id="@Model.OwnerId">
@Model.OwnerFullName
</a>
</dd>
- Clicking the owner’s name navigates to the Employees/Details page.
- Leverages tag helpers (
asp-controller,asp-action,asp-route-id).
4. Action Buttons
<div>
<a asp-action="Index" class="btn btn-danger irby-red">Index List</a>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-warning irby-orange">Update</a>
<a asp-action="History" asp-route-id="@Model.Id" class="btn btn-primary irby-violet">History</a>
</div>
- Index: Returns to the list of all desk phones.
- Update: Opens the edit form for this phone (
DeskPhones/Edit/{id}). - History: Shows change logs or maintenance records.
5. Client‑Side Scripts
<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 Bundle: Enables responsive UI, modals, tooltips.
- MetisMenu: Handles sidebar accordion menus.
- SimpleBar: Replaces native scrollbars for consistent look.
- Waves: Adds ripple effects on clickable elements.
🚦 Controller Endpoints Overview
Although this is purely a view, it participates in the following MVC routes:
| HTTP Method | URL | Purpose |
|---|---|---|
| GET | /DeskPhones/Index |
List all desk phones |
| GET | /DeskPhones/Details/{id} |
This view: show a specific phone |
| GET | /DeskPhones/Edit/{id} |
Edit form for a phone |
| GET | /DeskPhones/History/{id} |
Audit/history logs for a phone |
🔗 Third‑Party Integrations
- Bootstrap (UI framework)
- MetisMenu (collapsible menu)
- SimpleBar (scrollbars)
- Waves.js (click ripple effect)
These enrich the _ATSLayout shell and interactive elements on this page.
📐 UML Diagram
+--------------------------------------+
| DeskPhoneDetailViewModel |
+--------------------------------------+
| - MakeAndModel : string |
| - Status : string |
| - StatusColor : string |
| - Id : int |
| - SerialNumber : string |
| - PhoneNumber : string |
| - MacAddress : string |
| - PurchaseDate : DateTime |
| - OwnerFullName : string |
| - OwnerId : int |
| - Notes : string |
+--------------------------------------+
🖥️ Sample Usage Scenario
- User navigates to /DeskPhones/Index and clicks on a phone’s Details link.
- DeskPhonesController.Details(int id) populates a
DeskPhoneDetailViewModel. - The view renders the model: header, serial, owner link, and notes.
- The user can:
- Return to Index
- Click Update to modify phone details
- Click History to review change logs
// Controller snippet
public async Task<IActionResult> Details(int id)
{
var phone = await _context.DeskPhones
.Include(dp => dp.Owner)
.SingleOrDefaultAsync(dp => dp.Id == id);
if (phone == null) return NotFound();
var vm = new DeskPhoneDetailViewModel
{
Id = phone.Id,
MakeAndModel = $"{phone.Make} {phone.Model}",
Status = phone.Status.ToString(),
StatusColor = phone.Status == Status.Active ? "bg-success" : "bg-secondary",
SerialNumber = phone.SerialNumber,
PhoneNumber = phone.PhoneNumber,
MacAddress = phone.MacAddress,
PurchaseDate = phone.PurchaseDate,
OwnerFullName = $"{phone.Owner.FirstName} {phone.Owner.LastName}",
OwnerId = phone.OwnerId,
Notes = phone.Notes
};
return View(vm);
}
🏁 Conclusion
The Details.cshtml view provides a clear, structured, and interactive interface for viewing a desk phone’s full details within the IrbyImaging system. By leveraging ASP.NET Core Razor, tag helpers, and a shared layout, it ensures consistency, maintainability, and a seamless user experience.