📱 MobileDeviceDetailViewModel Documentation
Welcome to the detailed documentation for the MobileDeviceDetailViewModel class located at IrbyImaging/Models/MobileDevice/MobileDeviceDetailViewModel.cs. This ViewModel is part of the IrbyImaging.UI assembly and serves as the primary model for displaying and editing mobile device details in the UI.
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Class Definition & Inheritance
- Key Properties
- Warranty Status & Helpers
- Data Annotations & UI Display
- UML/Lucidchart Class Diagram
- Sample Usage in Razor View
- Conclusion
📖 1. Overview & Purpose
The MobileDeviceDetailViewModel is designed to encapsulate all the information needed to display, edit, and validate a mobile device record within the IrbyImaging UI layer. It inherits from a base DetailViewModel (which typically contains common properties like Id, CreatedOn, ModifiedOn, etc.) and adds mobile-specific fields:
- Device type (e.g., smartphone, tablet)
- Carrier information (service provider)
- Phone number, IMEI, SIM identifiers
- Warranty dates & computed states
- Review flags for internal processes
This class centralizes the state flags (IsOutOfWarranty, IsApproachingEndOfWarranty, WarrantyColorClass) so that the view can render appropriate calls-to-action (red/green badges, warnings, etc.) without additional logic.
⚙️ 2. Dependencies & Technologies
| Namespace | Purpose |
|---|---|
System |
Core .NET types (DateTimeOffset, etc.) |
System.ComponentModel.DataAnnotations |
Validation & UI metadata (Display attributes) |
IrbyImaging.Utility |
Shared utilities and enums (e.g., DeviceType, Carrier) |
IrbyImaging.Models |
Base ViewModel (DetailViewModel) |
- .NET Version: .NET 5+ (compatible with ASP.NET Core MVC/Razor)
- UI Framework: ASP.NET Core MVC with Razor Pages or MVC Views
- Annotations: Data Annotations for display metadata
📂 3. Class Definition & Inheritance
namespace IrbyImaging.Models
{
public class MobileDeviceDetailViewModel : DetailViewModel
{
// ... properties below ...
}
}
- Assembly:
IrbyImaging.UI - Author: kvamshi
- Created: 03-31-2022
Inheritance Hierarchy
DetailViewModel (base)
↳ MobileDeviceDetailViewModel
🔑 4. Key Properties
Below is a summary of all the properties defined in MobileDeviceDetailViewModel.
| Property Name | Type | Display Name | Description |
|---|---|---|---|
| Type | DeviceType |
Device Type | Enum indicating device category (e.g. Smartphone / Tablet). |
| Carrier | Carrier |
Service Provider | Enum representing the network carrier (e.g. Verizon, AT&T). |
| PhoneNumber | string |
Phone Number | The device’s phone number. |
| Imei | string |
IMEI | International Mobile Equipment Identity. |
| Sim | string |
SIM | SIM card identifier. |
| IsTelogis | string |
Telogis? | Text flag indicating if Telogis tracking is enabled. |
| EndOfWarranty | DateTimeOffset |
End Of Warranty | The date/time at which the warranty expires. |
| IsOutOfWarranty | bool |
— | Computed: true if current date > EndOfWarranty. |
| IsApproachingEndOfWarranty | bool |
— | Computed: true if within an alert window before EndOfWarranty. |
| WarrantyColorClass | string |
— | CSS class name for UI coloring based on warranty state (e.g. "text-danger"). |
| NeedsReview | bool |
Needs IT Review? | Flag to mark if the device requires manual IT review. |
🛠 5. Warranty Status & Helpers
While the ViewModel itself only stores the computed warranty flags and CSS class, typically these values are determined by a service or in the controller:
public void PopulateWarrantyFlags(MobileDeviceDetailViewModel model)
{
var now = DateTimeOffset.UtcNow;
model.IsOutOfWarranty = now > model.EndOfWarranty;
model.IsApproachingEndOfWarranty =
now <= model.EndOfWarranty && now >= model.EndOfWarranty.AddDays(-30);
model.WarrantyColorClass = model.IsOutOfWarranty
? "text-danger"
: model.IsApproachingEndOfWarranty
? "text-warning"
: "text-success";
}
👉 Use these flags in your Razor view to display badges or alerts:
<span class="@Model.WarrantyColorClass">
@if(Model.IsOutOfWarranty) { <text>⚠️ Out of Warranty</text> }
else if(Model.IsApproachingEndOfWarranty) { <text>⏳ Approaching</text> }
else { <text>✅ In Warranty</text> }
</span>
🏷 6. Data Annotations & UI Display
Each property intended for UI binding carries a [Display(Name = "...")] attribute:
- Ensures consistent labels in forms and detail pages.
- Supports localization by replacing the static
Namewith resource keys if needed. - Enables client- and server-side metadata generation for validation.
Example:
[Display(Name = "Service Provider")]
public Carrier Carrier { get; set; }
🗺 7. UML / Class Diagram
classDiagram
DetailViewModel <|-- MobileDeviceDetailViewModel
class DetailViewModel {
<<abstract>>
+Guid Id
+DateTimeOffset CreatedOn
+DateTimeOffset? ModifiedOn
// ... other shared props ...
}
class MobileDeviceDetailViewModel {
+DeviceType Type
+Carrier Carrier
+string PhoneNumber
+string Imei
+string Sim
+string IsTelogis
+DateTimeOffset EndOfWarranty
+bool IsOutOfWarranty
+bool IsApproachingEndOfWarranty
+string WarrantyColorClass
+bool NeedsReview
}
🔧 8. Sample Usage in Razor View
@model IrbyImaging.Models.MobileDeviceDetailViewModel
<h2>Device Details 📋</h2>
<div>
<dl class="row">
<dt class="col-sm-3">@Html.DisplayNameFor(m => m.Type)</dt>
<dd class="col-sm-9">@Html.DisplayFor(m => m.Type)</dd>
<dt class="col-sm-3">@Html.DisplayNameFor(m => m.Carrier)</dt>
<dd class="col-sm-9">@Html.DisplayFor(m => m.Carrier)</dd>
<dt class="col-sm-3">@Html.DisplayNameFor(m => m.PhoneNumber)</dt>
<dd class="col-sm-9">@Html.DisplayFor(m => m.PhoneNumber)</dd>
<dt class="col-sm-3">Warranty Status</dt>
<dd class="col-sm-9">
<span class="@Model.WarrantyColorClass">
@if(Model.IsOutOfWarranty) { <text>⚠️ Out of Warranty</text> }
else if(Model.IsApproachingEndOfWarranty) { <text>⏳ Approaching End</text> }
else { <text>✅ In Warranty</text> }
</span>
</dd>
</dl>
</div>
🔚 9. Conclusion
The MobileDeviceDetailViewModel is a focused, metadata‑rich model tailored for presenting mobile device details in the IrbyImaging UI. By centralizing data, validation metadata, and computed status flags, it simplifies view logic and ensures a clean separation of concerns between your controllers/services and Razor pages. 🚀
Feel free to extend this ViewModel with additional helper methods or validation attributes as your application’s requirements grow!