🏭 Manufacturer Class Documentation (IrbyImaging.DomainClasses)

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


📑 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Domain Data Model
  4. Class Definition & Code Snippet
  5. Property Reference
  6. Relationships & UML Diagram
  7. Usage & Examples
  8. Developer Notes & Best Practices
  9. Conclusion

1. Overview & Purpose

The Manufacturer class represents an asset manufacturer within the Irby Imaging domain. It models the entities that produce imaging equipment, including:

  • 📋 Basic metadata: Unique identifier, name.
  • 🗂️ Associated models: Collection of AssetModel entries manufactured.
  • ⚙️ Configuration options: Availability flag and warranty duration.

This class is a POCO (Plain Old CLR Object) used by Entity Framework (EF) Core to map to the database table irby.AssetManufacturer. It drives CRUD operations, querying, and relationships in the data layer.


2. Dependencies & Technologies

Component Purpose
System.ComponentModel.DataAnnotations Attributes for validation and metadata ([Key], [Display])
System.ComponentModel.DataAnnotations.Schema Mapping to tables & schemas ([Table], [Column])
System.Collections.Generic ICollection<T> for navigation properties
Entity Framework Core ORM for database interactions

3. Domain Data Model

  • Table: irby.AssetManufacturer
  • Primary Key: Id
  • Schema: irby

The manufacturer is a parent in a 1‑to‑many relationship with AssetModel.


4. Class Definition & Code Snippet

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace IrbyImaging.DomainClasses
{
    [Table("AssetManufacturer", Schema = "irby")]
    public class Manufacturer
    {
        [Key]
        public int Id { get; set; }

        public string Name { get; set; }

        public ICollection<AssetModel> Models { get; set; }

        [Display(Name = "Available?")]
        public bool IsAvailableOption { get; set; }

        public short? WarrantyMonths { get; set; }
    }
}

5. Property Reference

Property Type Description Annotation
Id int Unique identifier (PK) [Key]
Name string Manufacturer’s display name (none)
Models ICollection<AssetModel> Collection of related asset models (navigation property)
IsAvailableOption bool Indicates if manufacturer is an active selection option [Display(Name = "Available?")]
WarrantyMonths short? Default warranty period in months (nullable) (none)

6. Relationships & UML Diagram

Mermaid Class Diagram

classDiagram
    class Manufacturer {
        +int Id
        +string Name
        +bool IsAvailableOption
        +short? WarrantyMonths
        +ICollection<AssetModel> Models
    }
    class AssetModel {
        +int Id
        +string ModelName
        +int ManufacturerId
    }
    Manufacturer "1" --> "*" AssetModel : produces

7. Usage & Examples

7.1. Instantiation

var sony = new Manufacturer
{
    Name = "Sony",
    IsAvailableOption = true,
    WarrantyMonths = 24,
    Models = new List<AssetModel>()
};

7.2. Adding to DbContext

using (var context = new ImagingDbContext())
{
    context.Manufacturers.Add(sony);
    context.SaveChanges();
}

7.3. Querying

// Fetch all available manufacturers with their models
var availableMfrs = context.Manufacturers
    .Where(m => m.IsAvailableOption)
    .Include(m => m.Models)
    .ToList();

7.4. Updating Warranty

var mfr = context.Manufacturers.Find(3);
mfr.WarrantyMonths = 36;
context.SaveChanges();

8. Developer Notes & Best Practices

  • Null Checks: Although Name is non-nullable by convention, you may add [Required] if stricter enforcement is needed.
  • Cascade Deletes: Configure EF Core cascade rules if removing a manufacturer should remove its models.
  • Indexing: Consider adding indexes on Name if querying by manufacturer name is frequent.
  • Seed Data: Use EF Core’s HasData() to bootstrap common manufacturers.

9. Conclusion

The Manufacturer class is a foundational domain model that captures vendor details and links to equipment models. Leveraging Entity Framework Core, it provides a clear, annotated representation of the irby.AssetManufacturer table. With its simple structure and rich navigation properties, it empowers developers to manage manufacturer data efficiently, enforce business rules, and maintain referential integrity across the imaging asset domain.


Happy Coding! 🎉