πŸ“¦ Asset.cs Documentation

Assembly: IrbyImaging.DomainClasses
Namespace: IrbyImaging.DomainClasses
Author: kvamshi
Created: 03‑31‑2022
Last Modified: 03‑31‑2022


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. UML Class Diagram
  4. Asset Class – Properties
  5. Data Annotations & Validations
  6. Key Functional Areas
  7. Usage Examples
  8. Conclusion

🧐 Overview & Purpose

The Asset class represents a tangible or intangible resource tracked by Irby Imaging. Think of laptops, cameras, software licenses, or any equipment owned, assigned, or managed by the company. This domain model is mapped to the database table irby.Asset and supports:

  • 🎯 Asset Lifecycle Tracking (purchase, status, compliance)
  • πŸ”‘ Ownership & Location (assigned to an employee or field office)
  • πŸ“Š Reporting & Auditing (serial numbers, review flags, check-in timestamps)

πŸ”§ Dependencies & Technologies

Dependency Purpose
System Base .NET types (e.g., Guid, DateTimeOffset).
System.ComponentModel.DataAnnotations Declarative validation & metadata (e.g., [Key], [Required]).
System.ComponentModel.DataAnnotations.Schema ORM mapping attributes (e.g., [Table(...)]).
IrbyImaging.Utility Project‑wide utilities (e.g., AssetCategory, AssetStatus enums).
Entity Framework Core (implied) ORM to map the class to a relational database.

πŸ“ UML Class Diagram

classDiagram
    class Asset {
        +Guid Id
        +AssetCategory Category
        +DateTimeOffset PurchaseDate
        +AssetStatus Status
        +int ModelId
        +AssetModel Model
        +Guid? OwnerId
        +Employee Owner
        +Guid? FieldOfficeId
        +FieldOffice FieldOffice
        +string SerialNumber
        +string Notes
        +bool NeedsReview
        +string ComplianceStatus
        +DateTime LastCheckIn
        +string PrimaryUPN
    }
    Asset --> AssetModel : Model
    Asset --> Employee   : Owner
    Asset --> FieldOffice: FieldOffice

🏷️ Asset Class – Properties

Property Type Annotations Description
Id Guid [Key] πŸ”‘ Unique identifier for this asset.
Category AssetCategory [Required] πŸ—‚οΈ Category (e.g., Hardware, Software).
PurchaseDate DateTimeOffset [Required], [DataType(Date)] πŸ“… When the asset was acquired.
Status AssetStatus [Required] πŸ“‹ Current state (e.g., Active, Retired).
ModelId int [Required] πŸ†” FK to the AssetModel table.
Model AssetModel β€” πŸ”— Navigation property for the asset model.
OwnerId Guid? β€” πŸ†” Optional FK to an Employee.
Owner Employee β€” πŸ‘€ Navigation property to the employee.
FieldOfficeId Guid? β€” 🏒 Optional FK to a FieldOffice.
FieldOffice FieldOffice β€” 🌐 Navigation property to the field office.
SerialNumber string β€” πŸ”’ Manufacturer serial number or asset tag.
Notes string β€” πŸ“ Free‑text remarks or internal comments.
NeedsReview bool β€” ⚠️ Flag to signal compliance or audit review.
ComplianceStatus string β€” βœ”οΈ Current compliance outcome (e.g., β€œPass”).
LastCheckIn DateTime β€” ⏱️ Last heartbeat / location check timestamp.
PrimaryUPN string β€” πŸ“§ User Principal Name when assigned.

βœ… Data Annotations & Validations

  • [Table("Asset", Schema = "irby")]
    Maps this class to the irby.Asset table.
  • [Key]
    Marks Id as the primary key.
  • [Required]
    Ensures non-nullability in the database and at runtime for: Category, PurchaseDate, Status, ModelId.
  • [DataType(DataType.Date)]
    Restricts PurchaseDate to a date-only format (no time).

πŸš€ Key Functional Areas

  1. Lifecycle Management
    • PurchaseDate & Status track the asset’s journey.
  2. Ownership & Location
    • Owner vs. FieldOffice allow flexible assignment.
  3. Compliance & Auditing
    • NeedsReview, ComplianceStatus, LastCheckIn support periodic checks.
  4. Integration
    • Works seamlessly with AssetModel, Employee, and FieldOffice entities.
  5. Extendability
    • Add more properties (e.g., warranty, depreciation) without impacting core mapping.

πŸ’‘ Usage Examples

1. Creating a New Asset

var newAsset = new Asset
{
    Id              = Guid.NewGuid(),
    Category        = AssetCategory.Hardware,
    PurchaseDate    = DateTimeOffset.UtcNow,
    Status          = AssetStatus.Active,
    ModelId         = 123,                           // Must match an existing AssetModel
    SerialNumber    = "SN-ABC-001",
    Notes           = "Issued to new hire",
    NeedsReview     = false,
    ComplianceStatus= "Pending",
    LastCheckIn     = DateTime.UtcNow,
    PrimaryUPN      = "[email protected]"
};

// Using EF Core DbContext:
using(var context = new IrbyImagingContext())
{
    context.Assets.Add(newAsset);
    context.SaveChanges();
}

2. Querying & Updating

using(var context = new IrbyImagingContext())
{
    // Fetch all active hardware assets
    var assets = context.Assets
                        .Where(a => a.Status == AssetStatus.Active
                                 && a.Category == AssetCategory.Hardware)
                        .Include(a => a.Owner)
                        .Include(a => a.Model)
                        .ToList();

    // Mark one for review
    var asset = assets.First();
    asset.NeedsReview = true;
    asset.ComplianceStatus = "Scheduled";
    context.SaveChanges();
}

3. Navigation & Relationships

// Eager‑load relationships
var assetWithRelations = context.Assets
    .Include(a => a.Owner)
    .Include(a => a.FieldOffice)
    .Include(a => a.Model)
    .FirstOrDefault(a => a.Id == someGuid);

🏁 Conclusion

The Asset domain class is a cornerstone of the Irby Imaging asset-management solution. By leveraging Entity Framework Core conventions, rich annotations, and clear navigation properties, it:

  • πŸ“ˆ Promotes consistency in how assets are stored and retrieved.
  • πŸ”„ Eases extension for future properties (e.g., warranty, depreciation).
  • 🌐 Streams data seamlessly between the database and your application.

With this documentation, you now have a comprehensive understanding of what the Asset class is for, how it’s wired up, and how to use it in your codebase. Happy coding! πŸš€