π Mobile Device History View Documentation
Filename:
IrbyImaging/Views/MobileDevices/History.cshtml
Purpose: Renders a detailed view of a mobile deviceβs properties and its change/activity history in a userβfriendly timeline.
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Models & Data Models
- Key Functional Areas
4.1. Layout & Page Title
4.2. Details Section
4.3. Activity Timeline
4.4. Action Buttons - Helper Methods & Utilities
- Error Handling & Return Types
- Controller Integration & Endpoints
- Thirdβparty Integrations
- UML Class Diagram
- Sample Usage & Code Snippets
- Conclusion
1. Overview & Purpose
This Razor view displays:
- π Mobile Device Details (make/model, IMEI, serial number, warranty, etc.)
- π Activity Timeline showing every historical event (status changes, assignments, comments)
- π Action Buttons to navigate back to the index, see full details, or update the record.
It leverages a HistoryListViewModel passed from the controller, containing:
AssetId: ID of the mobile deviceMobileList: summary info (Make/Model, Carrier, Phone Number, Warranty)Histories: a chronologically ordered list of events
2. Dependencies & Technologies
| Category | Technology / Library |
|---|---|
| Frontβend Framework | Bootstrap 5 (bootstrap.bundle.min.js) |
| Layout & Menu | MetisMenu (metisMenu.min.js) |
| Custom Scrollbars | SimpleBar (simplebar.min.js) |
| Ripple Effects | NodeβWaves (waves.min.js) |
| Icon Set | Boxicons (bx bxβ* classes) |
| Serverβside | ASP.NET Core MVC / Razor view engine |
| Domain | IrbyImaging.DomainClasses.MobileDevice |
3. View Models & Data Models
3.1 HistoryListViewModel
| Property | Type | Description |
|---|---|---|
| AssetId | int |
Unique identifier of the mobile device |
| MobileList | MobileDeviceSummaryViewModel |
Summary data for header section |
| Histories | List<HistoryItemViewModel> |
Collection of history entries (events) |
3.2 MobileDeviceSummaryViewModel
| Property | Type | Description |
|---|---|---|
| MakeAndModel | string |
Combined device make and model name |
| Carrier | string |
Network provider (e.g., Verizon) |
| PhoneNumber | string |
Assigned phone number |
| EndOfWarranty | DateTime |
Warranty expiration date |
3.3 HistoryItemViewModel
| Property | Type | Description |
|---|---|---|
| Timestamp | DateTime |
When the event occurred |
| Owner | string |
Person currently assigned |
| OwnerId | int |
User ID for hyperlinking |
| Status | string |
Current status after the event |
| Reason | string |
Comments or description of change |
| SomeAsset | object |
Polymorphic referenceβdowncast to MobileDevice for details |
3.4 DomainClasses.MobileDevice
| Property | Type | Description |
|---|---|---|
| SerialNumber | string |
Device serial number |
| Imei | string |
International Mobile Equipment Identity |
| Sim | string |
SIM card identifier |
| IsTelogis | bool |
Is GPS tracking enabled |
| PurchaseDate | DateTime |
Date the device was purchased |
| Status | string |
Current operational status |
| Notes | string |
Arbitrary textual notes |
4. Key Functional Areas
4.1 Layout & Page Title
@model HistoryListViewModel
@{
ViewData["Title"] = "Mobile Device History";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<h2 style="color: #11467e"><u>MOBILE DEVICE HISTORY</u></h2>
Layout: Inherits the corporate layout_ATSLayout.cshtml.ViewData["Title"]: Browser tab title.
4.2 Details Section
A Bootstrap Card shows summary & technical details:
<div class="card">
<div class="card-body">
<h1 class="card-title mb-6 text-danger"><u><b>DETAILS</b></u></h1>
<h5><b>Make/Model:</b> <i class="text-primary">@Model.MobileList.MakeAndModel</i></h5>
<h5><b>Carrier:</b> <i class="text-primary">@Model.MobileList.Carrier</i></h5>
...
<h5><b>Warranty End Date:</b> <i class="text-primary">@Model.MobileList.EndOfWarranty.ToLocalTime()</i></h5>
<h5><b>Notes:</b>
<pre><i class="text-primary">@assetDetail.Notes</i></pre>
</h5>
</div>
</div>
assetDetail:
Extracts the first history entryβsvar asset = Model.Histories.FirstOrDefault(); var assetDetail = asset.SomeAsset as MobileDevice;MobileDevicepayload to display static fields.
4.3 Activity Timeline
A vertical timeline displaying each history event:
<ul class="verti-timeline list-unstyled">
@foreach (var item in Model.Histories)
{
<li class="event-list">
<div class="event-timeline-dot">
<i class="bx bx-right-arrow-circle"></i>
</div>
<div class="d-flex">
<div class="flex-shrink-0 me-3">
<i class="bx bx-time text-primary h5">@item.Timestamp.ToLocalTime()</i>
</div>
<div class="flex-grow-1">
<i class="bx bx-notepad h5"><b class="text-danger">Comment</b> - @item.Reason</i>
<i class="bx bx-user h5"><b class="text-danger">Assigned To</b> -
<a asp-controller="Employees" asp-action="Details" asp-route-id="@item.OwnerId">
@item.Owner
</a>
</i>
<i class="bx bx-analyse h5"><b class="text-danger">Status</b> - @item.Status</i>
</div>
</div>
</li>
}
</ul>
- π― Icons: Boxicons (
bx bx-time,bx bx-notepad, etc.). - π
ToLocalTime(): Ensures user sees local timezone.
4.4 Action Buttons
<div>
<a asp-action="Index" class="btn btn-danger irby-red">Index List</a>
<a asp-action="Details" asp-route-id="@Model.AssetId" class="btn btn-success irby-blue">Details</a>
<a asp-action="Edit" asp-route-id="@Model.AssetId" class="btn btn-warning irby-orange">Update</a>
</div>
- Navigate to index, fullβdetail view, or edit page.
- Buttons are colorβcoded to match corporate brand classes.
5. Helper Methods & Utilities
asp-controller/asp-action/asp-route-id: Tag helpers for generating proper URLs.- LINQ:
Model.Histories.FirstOrDefault()extracts the first record. - Conditional Casting:
as MobileDevicefor safe downcast.
6. Error Handling & Return Types
- Null Safety:
- If
Model.Historiesis empty,FirstOrDefault()returnsnullβ avoid accessing properties without checking.
- If
- HTML Encoding:
- Razor automatically HTMLβencodes
@item.Reason,@assetDetail.Notesto prevent XSS.
- Razor automatically HTMLβencodes
- ServerβSide Validation:
- Ensure the controller supplies a valid
HistoryListViewModel; otherwise returnNotFound()or redirect.
- Ensure the controller supplies a valid
7. Controller Integration & Endpoints
Typically backed by an MVC action:
public class MobileDevicesController : Controller
{
[HttpGet]
public IActionResult History(int id)
{
var model = _mobileDeviceService.GetHistoryList(id);
if (model == null) return NotFound();
return View(model);
}
}
- Route:
GET /MobileDevices/History/{id} - Returns:
View(HistoryListViewModel)
8. Thirdβparty Integrations
| Library | Purpose |
|---|---|
| Bootstrap 5 | Responsive layout & styling |
| MetisMenu | Sidebar navigation menu |
| SimpleBar | Custom scrollbars |
| NodeβWaves | Materialβstyle ripple effect |
| Boxicons | Scalable vector icons |
JS Includes at bottom of file:
<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>
9. UML Class Diagram
ββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββ
β HistoryListViewModel β 1 β MobileDeviceSummaryViewModelβ
βββββββββββββββββββββββββββββββΊβββββββββββββββββββββββββββββββ
β - AssetId : int β β - MakeAndModel : string β
β - MobileList : ... β β - Carrier : string β
β - Histories : List<HI> β β - PhoneNumber : string β
ββββββββββββββββββββββββββ β - EndOfWarranty : DateTime β
ββββββββββββββββββββββββββββββ
β
β *
βΌ
ββββββββββββββββββββββββββ
β HistoryItemViewModel β
ββββββββββββββββββββββββββ
β - Timestamp : DateTime β
β - Owner : string β
β - OwnerId : int β
β - Status : string β
β - Reason : string β
β - SomeAsset : object β
ββββββββββββββββββββββββββ
β downcast
βΌ
βββββββββββββββββββββββββββββ
β MobileDevice (Domain) β
βββββββββββββββββββββββββββββ
β - SerialNumber : string β
β - Imei : string β
β - Sim : string β
β - IsTelogis : bool β
β - PurchaseDate : DateTime β
β - Status : string β
β - Notes : string β
βββββββββββββββββββββββββββββ
10. Sample Usage & Code Snippets
10.1 Controller
// Fetch and render the history page
[HttpGet]
public IActionResult History(int id)
{
var model = _mobileService.GetHistoryListViewModel(id);
if (model == null) return NotFound();
return View("History", model);
}
10.2 Razor View Invocation
@model IrbyImaging.Models.HistoryListViewModel
@await Html.RenderPartialAsync("_Alerts")
<!-- The rest of History.cshtml -->
10.3 Link to Employee Details
<a asp-controller="Employees"
asp-action="Details"
asp-route-id="@item.OwnerId">
@item.Owner
</a>
11. Conclusion
β History.cshtml offers a comprehensive, chronological snapshot of a mobile deviceβs lifecycle. By combining summary cards, a timeline UI, and actionable buttons, the view empowers endβusers to:
- Quickly identify device status and key metadata.
- Drill down on assignments, comments, and status changes.
- Seamlessly navigate to related pages (index, details, edit).
This documentation should enable developers to maintain, extend, or integrate this view confidently into the larger IrbyImaging MVC application.
Happy coding! π