đ± IrbyImaging â Mobile Devices Index View Documentation
File:
IrbyImaging/Views/MobileDevices/Index.cshtml
Purpose: Renders an interactive list of mobile devices (phones, tablets, hotspots) with create, search, filter, export and CRUDâlike operations.
đ Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Models & Data Models
- Key Functional Areas
- ThirdâParty Integrations
- API Endpoints Overview
- Error Handling & Return Types
- Helper Methods & Utilities
- UML Class Diagram
- Usage Examples
- Conclusion
1. Overview & Purpose
This Razor view is the landing page for the Mobile Devices module of the IrbyImaging application. It:
- đŻ Displays a filtered list of mobile devices.
- â Provides buttons to add new devices by type (Phone, Tablet, Hotspot).
- đ Offers search and statusâfilter capabilities.
- đ Integrates DataTables for sorting, paging & exporting (CSV/Excel/Print).
- đ Links to Details, Update, and History actions.
2. Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| ASP.NET Core MVC + Razor | Serverâside view rendering |
| Bootstrap 4 | Responsive UI & styling |
| jQuery | DOM manipulations |
| DataTables (with Buttons extension) | Interactive tables & exporting |
| MetisMenu, SimpleBar, NodeâWaves | Layout & UI enhancements |
@Html.*, @Url.Action, Tag Helpers |
Razor & MVC integration |
@model MobileDeviceListViewModel
@{
ViewData["Title"] = "Mobile Device List";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
3. View Models & Data Models
MobileDeviceListViewModel
| Property | Type | Description |
|---|---|---|
IEnumerable<MobileDevice> MobileDevices |
List of devices | The devices to render in the table |
AssetStatus Status |
Enum | Current status filter |
int NumberApproachingEndOfWarranty |
int | Count of warranties nearing expiry |
int NumberOutOfWarranty |
int | Count of expired warranties |
MobileDevice
| Property | Type | Description |
|---|---|---|
string MakeAndModel |
string | Brand & model (e.g., âiPhone Xâ) |
string Imei |
string | IMEI number |
string Carrier |
string | Carrier network (e.g., âVerizonâ) |
string PhoneNumber |
string | Assigned phone number |
string OwnerFullName |
string | Employee ownerâs name |
DateTime PurchaseDate |
DateTime | Date of purchase |
DateTime EndOfWarranty |
DateTime | Warranty expiry date |
AssetStatus Status |
Enum | Current asset status |
bool NeedsReview |
bool | Flag for manual review |
bool IsTelogis |
bool | Telematics integration flag |
string WarrantyColorClass |
string | CSS class based on warranty status |
Enums
DeviceType { Phone, Tablet, Hotspot }AssetStatus { Active, Inactive, Maintenance, ⊠}
4. Key Functional Areas
Title & Layout
@{
ViewData["Title"] = "Mobile Device List";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<h2>
@Html.DisplayFor(m => m.Status) Mobile Devices
<span style="color:blue">@Model.MobileDevices.Count()</span>
</h2>
- ViewData["Title"] sets the browser title.
- Layout references the shared
_ATSLayout.cshtml. - The header shows the current status filter and the total count.
AddâNew Buttons
<div class="col-lg-5">
<a asp-action="Create" asp-route-deviceType="@DeviceType.Phone" class="btn-sm btn-success irby-green">
â Add New Cell Phone
</a>
<a asp-action="Create" asp-route-deviceType="@DeviceType.Tablet" class="btn-sm btn-success irby-green">
â Add New Tablet
</a>
<a asp-action="Create" asp-route-deviceType="@DeviceType.Hotspot" class="btn-sm btn-success irby-green">
â Add New Hotspot
</a>
</div>
- Generates three buttons that route to
MobileDevices/Create?deviceType={Phone|Tablet|Hotspot}.
Search & Filter Form
<form asp-action="Index" method="get">
<div class="input-group">
<input type="text" name="search" class="form-control" placeholder="Search for..." />
<div class="col-lg-4" style="float:right;">
@Html.DropDownListFor(
m => m.Status,
Html.GetEnumSelectList<AssetStatus>(),
new { @class = "form-control dropdown" }
)
</div>
<span class="input-group-addon">
<button type="submit" class="btn btn-primary irby-blue">Search</button>
</span>
</div>
</form>
- Keyword search via
name="search". - Status filter populated from
AssetStatusenum. - On submit,
Index(search, status)is called on the controller.
Data Table Markup
<table
id="mobileDevicesDatatable"
class="table table-striped table-bordered dt-responsive nowrap"
width="100%"
>
<thead>
<tr>
<th>@Html.DisplayNameFor(m => m.MobileDevices.First().MakeAndModel)</th>
<!-- ... other columns ... -->
<th>
Warranty
<span class="badge irby-orange">@Model.NumberApproachingEndOfWarranty</span>
<span class="badge irby-red">@Model.NumberOutOfWarranty</span>
</th>
<th>Details</th>
<th>Update</th>
<th>History</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.MobileDevices) {
<tr class="@item.WarrantyColorClass">
<td>@item.MakeAndModel</td>
<!-- ... other fields ... -->
<td>
<a href="@Url.Action("Details", "MobileDevices", new { id = item.Id })"
class="btn-sm btn-info">
Details <img src="~/details.png" style="width:20px;" />
</a>
</td>
<td>
<a href="@Url.Action("Edit", "MobileDevices", new { id = item.Id })"
class="btn-sm btn-warning">
Update <img src="~/update.png" style="width:23px;" />
</a>
</td>
<td>
<a href="@Url.Action("History", "MobileDevices", new { id = item.Id })"
class="btn-sm btn-primary">
History <img src="~/history.png" style="width:23px;" />
</a>
</td>
</tr>
}
</tbody>
</table>
- Dynamically builds each row from
Model.MobileDevices. - Uses
@item.WarrantyColorClassto highlight warranty status (e.g., red for expired).
Scripts & DataTables Initialization
@section Scripts {
<!-- jQuery & DataTables core -->
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<!-- Buttons extension + dependencies -->
<script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>
<!-- Init DataTable -->
<script>
$(document).ready(function () {
$('#mobileDevicesDatatable').DataTable({
dom: 'Bfrtip',
buttons: ['csv', 'excel', 'print']
});
});
</script>
}
- DataTables is initialized with export buttons: CSV, Excel, Print.
- Loaded via CDN for simplicity.
5. ThirdâParty Integrations
| Library | Usage |
|---|---|
| DataTables (+ Buttons) | Sorting, paging, live export |
| jQuery CDN | DOM ready & DataTables dependency |
| Bootstrap 4 CSS/JS | Grid system, form controls, button styling |
| MetisMenu, SimpleBar, NodeâWaves (bundled) | Global layout & effects (via _ATSLayout) |
6. API Endpoints Overview
Although this is purely a view, it ties into the following controller actions in MobileDevicesController:
| Action | HTTP Method | Route | Notes |
|---|---|---|---|
| Index | GET | /MobileDevices?search=&status= |
Renders this view |
| Create | GET/POST | /MobileDevices/Create?deviceType= |
Add new device |
| Details | GET | /MobileDevices/Details/{id} |
Show device details |
| Edit | GET/POST | /MobileDevices/Edit/{id} |
Update device info |
| History | GET | /MobileDevices/History/{id} |
View device change history |
7. Error Handling & Return Types
- Model Validation: Standard ASP.NET Core validation for Create/Edit POST actions.
- NotFound(): If an ID is invalid in Details/Edit/History, the controller returns
NotFound(). - RedirectToAction("Index"): On success for Create/Edit to refresh the list.
8. Helper Methods & Utilities
@Html.DisplayFor(...)@Html.DisplayNameFor(...)@Html.DropDownListFor(model â ..., Html.GetEnumSelectList<AssetStatus>())@Url.Action("Action", "Controller", new { ... })Html.GetEnumSelectList<TEnum>()â extension to build<select>from an enum.
9. UML Class Diagram
@startuml
class MobileDeviceListViewModel {
- IEnumerable<MobileDevice> MobileDevices
- AssetStatus Status
- int NumberApproachingEndOfWarranty
- int NumberOutOfWarranty
}
class MobileDevice {
- string MakeAndModel
- string Imei
- string Carrier
- string PhoneNumber
- string OwnerFullName
- DateTime PurchaseDate
- DateTime EndOfWarranty
- AssetStatus Status
- bool NeedsReview
- bool IsTelogis
- string WarrantyColorClass
}
enum AssetStatus { Active; Inactive; Maintenance; /* ⊠*/ }
MobileDeviceListViewModel --> "0..*" MobileDevice
MobileDeviceListViewModel --> AssetStatus
@enduml
10. Usage Examples
Controller
public IActionResult Index(AssetStatus? status, string search) {
var devices = _mobileDeviceService.GetAll(status, search);
var model = new MobileDeviceListViewModel {
Status = status ?? AssetStatus.Active,
MobileDevices = devices,
NumberApproachingEndOfWarranty = devices.Count(d => d.EndOfWarranty < DateTime.Today.AddMonths(1)),
NumberOutOfWarranty = devices.Count(d => d.EndOfWarranty < DateTime.Today)
};
return View(model);
}
Razor Link to Employee Details
<a asp-controller="Employees"
asp-action="Details"
asp-route-id="@item.OwnerId">
@item.OwnerFullName
</a>
11. Conclusion
The Index.cshtml view in the MobileDevices folder is a featureârich, dataâdriven page that:
- Presents a dynamic, exportable table of corporate mobile assets.
- Empowers users to create, filter, view, update, and audit history of devices.
- Leverages industryâstandard libraries (DataTables, Bootstrap) for a polished UX.
By understanding each section aboveâmodels, markup, scripts, and integration pointsâdevelopers can confidently extend, customize, or reuse this view for new scenarios in the IrbyImaging platform.
Enjoy building with †IrbyImaging!