π Equipment.cs Documentation
Welcome to the Equipment class documentation! This file defines the core ViewModel for representing and manipulating equipment assets within the IrbyImaging application.
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Class Definition & Key Functional Areas
- Properties Reference
- Data Annotations & UI Support
- Usage Examples
- UML Class Diagram
- Conclusion
π Overview & Purpose
The Equipment ViewModel encapsulates all the information needed to:
- Display equipment details in list and detail views
- Create or edit equipment records via forms
- Filter and search equipment, including historical data
This class bridges the controller logic and the Razor views, ensuring strong typing and easy data binding.
π Dependencies & Technologies
- Language & Platform: C# on .NET Core / .NET 5+
- Framework: ASP.NET Core MVC
- Data Annotations:
System.ComponentModel.DataAnnotationsSystem.ComponentModel.DataAnnotations.Schema
- UI Helpers:
Microsoft.AspNetCore.Mvc.Rendering.SelectListItemfor dropdowns
- Collections:
System.Collections.Generic
π§© Class Definition & Key Functional Areas
namespace IrbyImaging.UI.Models
{
public class Equipment
{
// Unique Identifier
public Guid EquipmentId { get; set; }
// Primary Names & Codes
public string Name { get; set; }
public string DisplayName { get; set; }
public string AssetNumber { get; set; }
public string UnitTagNumber { get; set; }
public string SerialNumber { get; set; }
// Dates
[DataType(DataType.Date)]
public DateTime? DateAcquired { get; set; }
[DataType(DataType.Date)]
public DateTime? DateDisposed { get; set; }
// Descriptions & Remarks
public string Description { get; set; }
public string AssetRemark { get; set; }
public string AssetRemark2 { get; set; }
// Financial & Accounting
public string FinanceMethod { get; set; }
public decimal PurchasePrice { get; set; }
public string RateGroup { get; set; }
public string AccountingClass { get; set; }
// Classification
public string EquipmentClass { get; set; }
public string EquipmentType { get; set; }
public string AssetManufacturer { get; set; }
public string Year { get; set; }
public string FuelType { get; set; }
public string PreventiveMaintCatDesc { get; set; }
public string DeviceType { get; set; }
public string Division { get; set; }
// Status & Lifecycle
public string Status { get; set; }
public string CurrentStatus { get; set; }
// Job Assignment
public Guid? JobId { get; set; }
public string JobNumber { get; set; }
public DateTime? BeginDate { get; set; }
public DateTime? EndDate { get; set; }
// UI Dropdown Data
public List<SelectListItem> EquipmentClasses { get; set; }
public List<SelectListItem> EquipmentTypes { get; set; }
// Search Options
public bool SearchHistory { get; set; }
}
}
Key Functional Areas
- Identification & Tracking: IDs, serial numbers, asset tags
- Lifecycle Management: acquisition/disposal dates, status
- Financial & Accounting: purchase price, finance methods
- Classification & Filtering: equipment class/type, manufacturer, fuel type
- Job Assignment: linking equipment to jobs/orders
- UI Support: populating
<select>dropdowns for class/type - Search Control: include historical records
π Properties Reference
| Property | Type | Description |
|---|---|---|
| EquipmentId | Guid |
π Unique key for the equipment record. |
| Name | string |
π·οΈ Internal code or system name. |
| DisplayName | string |
π User-friendly name. |
| AssetNumber | string |
# Official asset tracking number. |
| UnitTagNumber | string |
# Unit tag or label number. |
| SerialNumber | string |
# Manufacturerβs serial number. |
| DateAcquired | DateTime? |
π When the equipment was acquired. |
| DateDisposed | DateTime? |
π When the equipment was disposed/sold. |
| Description | string |
π Detailed description. |
| FinanceMethod | string |
π° How the purchase was financed. |
| PurchasePrice | decimal |
π΅ Cost of purchase. |
| RateGroup | string |
π·οΈ Billing or rate group. |
| AccountingClass | string |
π GL class or ledger code. |
| EquipmentClass | string |
π Category for equipment. |
| EquipmentType | string |
π Sub-category or type. |
| AssetManufacturer | string |
π Maker/brand of the equipment. |
| Year | string |
π Model or manufacture year. |
| FuelType | string |
β½ Fuel or power type. |
| PreventiveMaintCatDesc | string |
π§ Maintenance category description. |
| DeviceType | string |
βοΈ Device classification. |
| Division | string |
π’ Business division or department. |
| AssetRemark, AssetRemark2 | string |
ποΈ Additional remarks or notes. |
| Status | string |
π¦ Current status (Active, In Repair, etc.). |
| CurrentStatus | string |
π¦ Live status for UI display. |
| JobId | Guid? |
π οΈ Related job/order GUID. |
| JobNumber | string |
π οΈ External job number. |
| BeginDate, EndDate | DateTime? |
π Job assignment start/end dates. |
| EquipmentClasses | List<SelectListItem> |
ποΈ Dropdown list items for equipment classes. |
| EquipmentTypes | List<SelectListItem> |
ποΈ Dropdown list items for equipment types. |
| SearchHistory | bool |
π Toggle to include historical records in search results. |
π Data Annotations & UI Support
-
[DataType(DataType.Date)]
- Applied to
DateAcquired,DateDisposed - Ensures date-only rendering in Razor views and proper client-side validation.
- Applied to
-
SelectListItem Collections
- EquipmentClasses & EquipmentTypes are populated by the controller
- Enable
<select asp-for="..." asp-items="...">in Razor for dynamic dropdowns.
π Usage Examples
1. Controller: Populating Dropdowns
public IActionResult Create()
{
var model = new Equipment
{
EquipmentClasses = _lookupService.GetEquipmentClasses()
.Select(c => new SelectListItem(c.Name, c.Id))
.ToList(),
EquipmentTypes = _lookupService.GetEquipmentTypes()
.Select(t => new SelectListItem(t.Name, t.Id))
.ToList()
};
return View(model);
}
2. Razor View: Equipment Form
@model IrbyImaging.UI.Models.Equipment
<form asp-action="Create" method="post">
<div class="form-group">
<label asp-for="DisplayName"></label>
<input asp-for="DisplayName" class="form-control" />
<span asp-validation-for="DisplayName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="EquipmentClass">Class</label>
<select asp-for="EquipmentClass" asp-items="Model.EquipmentClasses" class="form-control">
<option value="">-- Select Class --</option>
</select>
</div>
<div class="form-group">
<label asp-for="DateAcquired"></label>
<input asp-for="DateAcquired" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">Save</button>
</form>
3. Controller: Searching with History Flag
public IActionResult Index(bool searchHistory = false)
{
var results = _equipmentService.Search(searchHistory);
return View(results);
}
π UML Class Diagram
classDiagram
class Equipment {
+Guid EquipmentId
+string Name
+string DisplayName
+string AssetNumber
+string UnitTagNumber
+string SerialNumber
+DateTime? DateAcquired
+DateTime? DateDisposed
+string Description
+string FinanceMethod
+decimal PurchasePrice
+string RateGroup
+string AccountingClass
+string EquipmentClass
+string EquipmentType
+string AssetManufacturer
+string Year
+string FuelType
+string PreventiveMaintCatDesc
+string DeviceType
+string Division
+string AssetRemark
+string AssetRemark2
+string Status
+string CurrentStatus
+Guid? JobId
+string JobNumber
+DateTime? BeginDate
+DateTime? EndDate
+List<SelectListItem> EquipmentClasses
+List<SelectListItem> EquipmentTypes
+bool SearchHistory
}
β Conclusion
The Equipment class is a comprehensive ViewModel tailored for the IrbyImaging UI. It provides:
- Strongly-typed properties to streamline data binding
- Built-in data annotations for validation & formatting
- Dropdown support via
SelectListItemcollections - Flags for advanced search scenarios (e.g., historical records)
By leveraging this model, developers can rapidly build CRUD interfaces, ensure data consistency, and maintain a clear separation of concerns between the UI and business logic. π
Happy coding! π