πŸ›‘οΈ SafetyEquipment.cs Documentation

Assembly: IrbyImaging.DomainClasses
Namespace: IrbyImaging.DomainClasses


πŸ“– Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. UML Class Diagram
  4. Key Functional Areas
  5. Data Model: Properties
  6. Constructor
  7. View Models & Data Models
  8. Helper Methods / Utilities
  9. Error Handling & Return Types
  10. API Endpoints Overview
  11. Third-Party Integrations
  12. Sample Code Blocks
  13. Usage Examples
  14. Conclusion

1. Overview & Purpose

πŸ“ SafetyEquipment is a domain model representing safety-related assets within the Irby Imaging system.
It inherits from the base class Asset to leverage common properties (e.g., Id, Name, PurchaseDate) while adding safety-specific fields:

  • Categorization: Automatically tagged as AssetCategory.SafetyEquipment
  • Identification: Tracks operating system reference, asset/unit/CPS numbers

This class is intended to be used in:

  • Entity Framework or any ORM for persistence
  • Business logic that needs specialized safety-asset behaviors
  • UI layers for displaying or editing safety equipment details

2. Dependencies & Technologies

Technology / Library Purpose
C# (.NET Standard or .NET 6+) Core language and runtime
IrbyImaging.DomainClasses Domain assembly
IrbyImaging.Utility Defines AssetCategory enum
Entity Framework (optional) ORM for database mapping

Note: The OperatingSystem navigation property typically ties into another domain class or lookup table.


3. UML Class Diagram

classDiagram
    class Asset {
        <<abstract>>
        +int Id
        +string Name
        +DateTime PurchaseDate
        +AssetCategory Category
        +... // Other common asset props
    }
    class SafetyEquipment {
        +int OperatingSystemId
        +OperatingSystem OperatingSystem
        +string AssetNumber
        +string UnitNumber
        +string CpsNumber
        +SafetyEquipment()
    }
    class OperatingSystem {
        +int Id
        +string Name
        +string Version
        +... // Additional OS fields
    }

    Asset <|-- SafetyEquipment
    OperatingSystem "1" <-- "0..*" SafetyEquipment

4. Key Functional Areas

  • Domain Modeling: Defines a strong-typed representation of safety equipment in the system.
  • Category Assignment: Automatically sets Category = AssetCategory.SafetyEquipment upon instantiation.
  • Data Relationships: Links to an OperatingSystem entity via foreign key (OperatingSystemId).
  • Unique Identifiers:
    • AssetNumber – System-wide unique asset tag
    • UnitNumber – Manufacturer or internal unit code
    • CpsNumber – Certification or safety compliance ID

5. Data Model: Properties

Property Type Description
OperatingSystemId int Foreign key to the associated operating system.
OperatingSystem OperatingSystem Navigation property for ORM relationships.
AssetNumber string Unique identifier assigned by asset management.
UnitNumber string Manufacturer or site unit code.
CpsNumber string Certification or Safety Compliance number.

6. Constructor

/// <summary>
/// Initializes a new instance of the <see cref="SafetyEquipment"/> class.
/// Automatically sets the asset category to SafetyEquipment.
/// </summary>
public SafetyEquipment()
{
    Category = IrbyImaging.Utility.AssetCategory.SafetyEquipment;
}
  • What it does:
    • Calls base Asset constructor (implicitly).
    • Sets Category to SafetyEquipment, ensuring consistency across all safety assets.

7. View Models & Data Models

  • View Models
    • Typically you would map SafetyEquipment to a SafetyEquipmentViewModel for UI concerns (e.g., with AutoMapper).
  • Data Models
    • This class is the data model for EF or other ORMs.
    • Tables:
      • Assets (base)
      • SafetyEquipments (derived)

8. Helper Methods / Utilities

πŸ”§ Note: This class does not define custom helper methods beyond the constructor. All logic resides in the base Asset or in service layers.


9. Error Handling & Return Types

  • Error Handling:
    • None within this POCO.
    • Validation and exceptions should be handled in service or application layers (e.g., null checks, required fields).
  • Return Types:
    • All members are simple propertiesβ€”no methods returning values.

10. API Endpoints Overview

⚠️ This is a domain class and does not define API endpoints.
API controllers that expose SafetyEquipment may provide endpoints such as:

  • GET /api/safetyequipment/{id}
  • POST /api/safetyequipment
  • PUT /api/safetyequipment/{id}
  • DELETE /api/safetyequipment/{id}

11. Third-Party Integrations

  • Entity Framework Core (or EF6) for object-relational mapping.
  • FluentValidation or DataAnnotations (not shown) may be used to validate properties at the service or API level.

12. Sample Code Blocks

12.1. Defining the DbContext

public class ImagingDbContext : DbContext
{
    public DbSet<Asset> Assets { get; set; }
    public DbSet<SafetyEquipment> SafetyEquipments { get; set; }
    public DbSet<OperatingSystem> OperatingSystems { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<SafetyEquipment>()
            .HasOne(se => se.OperatingSystem)
            .WithMany(os => os.SafetyEquipments)
            .HasForeignKey(se => se.OperatingSystemId);

        base.OnModelCreating(modelBuilder);
    }
}

12.2. Migration Example

dotnet ef migrations add AddSafetyEquipmentTable
dotnet ef database update

13. Usage Examples

13.1. Creating a New Safety Equipment

var os = new OperatingSystem { Name = "Windows", Version = "10 Pro" };
context.OperatingSystems.Add(os);
context.SaveChanges();

var helmet = new SafetyEquipment
{
    OperatingSystemId = os.Id,
    AssetNumber = "SE-2023-0001",
    UnitNumber = "HN-XL-42",
    CpsNumber = "CPS-889977"
};
context.SafetyEquipments.Add(helmet);
context.SaveChanges();

13.2. Querying Safety Equipment

var allSafetyDevices = context.SafetyEquipments
    .Include(se => se.OperatingSystem)
    .Where(se => se.OperatingSystem.Name == "Windows")
    .ToList();

14. Conclusion

πŸ› οΈ SafetyEquipment.cs provides a clean, extendable domain model for managing safety-related assets. By inheriting from the common Asset class and assigning a specific category, it simplifies tracking, validation, and persistence. Use it in combination with EF Core and your service/API layers to deliver robust safety equipment management in your application.


πŸŽ‰ Happy coding and stay safe with well-modelled assets!