πŸ“˜ SafetyEquipmentDetailViewModel.cs Documentation


πŸ“‘ Table of Contents

  1. 🌟 Overview & Purpose
  2. πŸ“¦ Dependencies & Technologies
  3. 🧩 Inheritance & UML Diagram
  4. πŸ”‘ Key Functional Areas
  5. πŸ“„ Detailed Property Reference
  6. πŸ› οΈ Usage Examples
  7. βœ… Validation & Error Handling
  8. πŸš€ Integration & MVC View Snippet
  9. 🎯 Conclusion

🌟 Overview & Purpose

The SafetyEquipmentDetailViewModel is part of the IrbyImaging.UI assembly. It extends a common DetailViewModel to encapsulate all the data required for displaying detailed safety equipment information in an ASP.NET MVC or Razor Pages application.

Intended Use

  • Supply strongly-typed data to a detail/edit view for safety equipment.
  • Leverage Data Annotations for display names and data formatting.
  • Compute UI-centric flags (e.g., warranty status) to visually guide end users.

πŸ“¦ Dependencies & Technologies

Technology / Library Version/Notes
.NET (Core / Framework) Any supporting DateTimeOffset
ASP.NET MVC / Razor Pages For model binding & views
System.ComponentModel.DataAnnotations For [Display], [DataType]

The model resides in the namespace:

namespace IrbyImaging.Models

🧩 Inheritance & UML Diagram

+---------------------------+
|      DetailViewModel      |  ← Base class with common properties (Id, Name, etc.)
+---------------------------+
            β–²
            β”‚
+----------------------------------------+
| SafetyEquipmentDetailViewModel         |
+----------------------------------------+
| + string OperatingSystem               |
| + string AssetNumber                   |
| + string UnitNumber                    |
| + string CpsNumber                     |
| + DateTimeOffset PurchaseDate          |
| + DateTimeOffset EndOfWarranty         |
| + bool IsApproachingEndOfWarranty      |
| + bool IsOutOfWarranty                 |
| + string WarrantyColorClass            |
+----------------------------------------+
  • Note: SafetyEquipmentDetailViewModel inherits from DetailViewModel (common properties like Id, Name, etc., are defined there).

πŸ”‘ Key Functional Areas

  1. Identification Properties

    • Asset tracking via JDE Asset & Unit numbers
    • CPS (Component Part Serial) number
  2. Warranty & Certification

    • PurchaseDate (the tested or purchase date)
    • EndOfWarranty (certification expiration)
    • Color-coded UI class (WarrantyColorClass)
  3. Status Indicators

    • IsApproachingEndOfWarranty (true if within a warning window)
    • IsOutOfWarranty (true if expired)

πŸ“„ Detailed Property Reference

Property Type Attributes Description
OperatingSystem πŸ“€ string [Display("Operating System/Size")] OS or size specification of the safety equipment
AssetNumber 🏷️ string [Display("JDE Asset Number")] Unique JDE asset identifier
UnitNumber πŸ”’ string [Display("JDE Unit Number")] JDE unit number within the asset
CpsNumber πŸ”– string [Display("CPS Number")] Component Part Serial number
PurchaseDate πŸ“… DateTimeOffset [DataType(DataType.Date)][Display("Tested Date")] Date of purchase or last test
EndOfWarranty βŒ› DateTimeOffset [DataType(DataType.Date)][Display("End Certification Date")] Certification expiry date
IsApproachingEndOfWarranty ⚠️ bool β€” Flag indicating near-expiry (used for warning color coding)
IsOutOfWarranty ❌ bool β€” Flag indicating warranty/certification has expired
WarrantyColorClass 🎨 string β€” CSS class (e.g., "text-warning", "text-danger") for UI color

πŸ› οΈ Usage Examples

Instantiating in C#

var model = new SafetyEquipmentDetailViewModel
{
    Id                        = 101,
    Name                      = "Portable Gas Detector",
    OperatingSystem           = "OS v3.1 / Compact",
    AssetNumber               = "ASSET-12345",
    UnitNumber                = "UNIT-67890",
    CpsNumber                 = "CPS-54321",
    PurchaseDate              = DateTimeOffset.Parse("2021-04-15"),
    EndOfWarranty             = DateTimeOffset.Parse("2023-04-15"),
    IsApproachingEndOfWarranty = DateTimeOffset.Now.AddDays(30) >= DateTimeOffset.Parse("2023-04-15"),
    IsOutOfWarranty           = DateTimeOffset.Now > DateTimeOffset.Parse("2023-04-15"),
    WarrantyColorClass        = (DateTimeOffset.Now > DateTimeOffset.Parse("2023-04-15")) 
                                ? "text-danger" 
                                : "text-warning"
};

Checking Warranty Status

if (model.IsOutOfWarranty)
{
    Console.WriteLine("⚠️ This equipment is out of warranty!");
}
else if (model.IsApproachingEndOfWarranty)
{
    Console.WriteLine("⚠️ Warranty nearing expiration!");
}
else
{
    Console.WriteLine("βœ… Equipment is within warranty.");
}

βœ… Validation & Error Handling

  • Required Attributes: No [Required] attributes are active by default, but you can uncomment or add them as needed to enforce user input.
  • Date Formatting: The [DataType(DataType.Date)] annotation ensures HTML5 date pickers and consistent formatting.
  • Display Names: Controlled via [Display(Name = "...")] to render friendly labels in views.

πŸš€ Integration & MVC View Snippet

Below is a Razor snippet illustrating how to render this ViewModel in an ASP.NET MVC view:

@model IrbyImaging.Models.SafetyEquipmentDetailViewModel

<h2>Safety Equipment Details</h2>
<dl class="row">
    <dt class="col-sm-3">@Html.DisplayNameFor(m => m.OperatingSystem)</dt>
    <dd class="col-sm-9">@Html.DisplayFor(m => m.OperatingSystem)</dd>

    <dt class="col-sm-3">@Html.DisplayNameFor(m => m.AssetNumber)</dt>
    <dd class="col-sm-9">@Html.DisplayFor(m => m.AssetNumber)</dd>

    <dt class="col-sm-3">@Html.DisplayNameFor(m => m.UnitNumber)</dt>
    <dd class="col-sm-9">@Html.DisplayFor(m => m.UnitNumber)</dd>

    <dt class="col-sm-3">@Html.DisplayNameFor(m => m.CpsNumber)</dt>
    <dd class="col-sm-9">@Html.DisplayFor(m => m.CpsNumber)</dd>

    <dt class="col-sm-3">@Html.DisplayNameFor(m => m.PurchaseDate)</dt>
    <dd class="col-sm-9">@Html.DisplayFor(m => m.PurchaseDate)</dd>

    <dt class="col-sm-3">@Html.DisplayNameFor(m => m.EndOfWarranty)</dt>
    <dd class="col-sm-9">
        <span class="@Model.WarrantyColorClass">
            @Html.DisplayFor(m => m.EndOfWarranty)
        </span>
    </dd>
</dl>

🎯 Conclusion

The SafetyEquipmentDetailViewModel is your go‑to model for displaying, editing, and validating safety equipment records in the IrbyImaging UI. Its combination of typed properties, display annotations, and warranty-status flags makes it straightforward to integrate into ASP.NET MVC or Razor Pages viewsβ€”complete with color‑coded visual cues for critical warranty information. Happy coding! πŸš€