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

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Class Definition & Key Functional Areas
  4. Properties Reference
  5. Data Annotations & UI Support
  6. Usage Examples
  7. UML Class Diagram
  8. 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.DataAnnotations
    • System.ComponentModel.DataAnnotations.Schema
  • UI Helpers:
    • Microsoft.AspNetCore.Mvc.Rendering.SelectListItem for 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.
  • 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 SelectListItem collections
  • 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! πŸŽ‰