πŸ“‹ 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

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Models & Data Models
  4. Key Functional Areas
    4.1. Layout & Page Title
    4.2. Details Section
    4.3. Activity Timeline
    4.4. Action Buttons
  5. Helper Methods & Utilities
  6. Error Handling & Return Types
  7. Controller Integration & Endpoints
  8. Third‑party Integrations
  9. UML Class Diagram
  10. Sample Usage & Code Snippets
  11. 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 device
  • MobileList: 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:
    var asset = Model.Histories.FirstOrDefault();
    var assetDetail = asset.SomeAsset as MobileDevice;
    
    Extracts the first history entry’s MobileDevice payload 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 MobileDevice for safe downcast.

6. Error Handling & Return Types

  • Null Safety:
    • If Model.Histories is empty, FirstOrDefault() returns null β†’ avoid accessing properties without checking.
  • HTML Encoding:
    • Razor automatically HTML‑encodes @item.Reason, @assetDetail.Notes to prevent XSS.
  • Server‑Side Validation:
    • Ensure the controller supplies a valid HistoryListViewModel; otherwise return NotFound() or redirect.

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 -->
<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! πŸš€