IrbyImaging.DomainClasses/Job.cs 📄

Welcome to the comprehensive documentation for the Job.cs class in the IrbyImaging.DomainClasses assembly. This guide covers everything from high‑level architecture and UML diagrams to code snippets and practical usage examples.


Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies 🔗
  3. UML Class Diagram 🎨
  4. Key Functional Areas 📂
  5. Property Reference Table 📋
  6. Usage Examples 💡
  7. Integration with EF Core & Query Samples 🛠️
  8. Conclusion & Next Steps ✅

1. Overview & Purpose

What is Job.cs?
Job.cs is a Domain Model representing a Job (or Project) entity in the IrbyImaging application. It captures all relevant metadata about a job, including identifiers, timelines, personnel assignments, financials, and geolocation.

Intended Use:

  • Persist job data to a relational database via Entity Framework Core
  • Expose job information to business logic, services, and eventual APIs
  • Serve as a backbone for reporting, scheduling, and resource allocation

2. Dependencies & Technologies 🔗

  • .NET 6+ / .NET Standard
  • Entity Framework Core (DataAnnotations for mapping)
  • System.ComponentModel.DataAnnotations
  • System.ComponentModel.DataAnnotations.Schema
  • IrbyImaging.Utility (for JobStatus enum)

3. UML Class Diagram 🎨

Below is an ASCII UML diagram illustrating the Job class and its main relationships:

                    +----------------------+
                    |        Job           |
                    +----------------------+
                    | - JobId: Guid        |
                    | - JdeNumber: string  |
                    | - Name: string       |
                    | - JobType: string    |
                    | - ContractType: str. |
                    | - WorkType: string   |
                    | - Status: JobStatus  |
                    | - ... (other fields) |
                    +----------------------+
                    | + Employees: ICollection<Employee> |
                    | + Manager: Employee [NotMapped]   |
                    | + Superintendent: Employee [N.M.] |
                    | + ProjectEstimator: Employee [N.M.] |
                    | + Customer: Customer [NotMapped]  |
                    | + FieldOffice: FieldOffice [N.M.] |
                    +----------------------+

Relationships

  • Job 1–* Employee (Employees assigned to the job)
  • Job *–1 Customer (Client behind the job)
  • Job *–1 FieldOffice (Office overseeing the job)

4. Key Functional Areas 📂

4.1 Data Model Properties

  • Identifiers & Basic Info

    • JobId (Guid): Primary key.
    • JdeNumber (string): External JDE system reference.
    • Name (string): Friendly name or title.
  • Timeline

    • DatePlannedStart / DatePlannedComplete (DateTime?)
    • DateActualStart / DateActualComplete (DateTime?)
  • Financials & Budgets

    • BudgetRequested, BudgetApproved, BeginningBudget (decimal)
    • BudgetChange, CommitmentChange (decimal)
  • Geolocation & Region

    • GeoRegionCode, GeoRegionDescription (string)
    • AddressLine1/2, City, State, ZipCode, Country

4.2 Relationships & Navigation Properties

  • Employees
    • ICollection<Employee> Employees: All employees on the job.
  • Role-specific Persons ([NotMapped] for on‑the‑fly population)
    • Manager, ProjectEstimator, Superintendent
  • Customer & Field Office
    • CustomerId (Guid?), Customer (Navigation, [NotMapped])
    • FieldOfficeId (Guid?), FieldOffice (Navigation, [NotMapped])

4.3 Mapping & Data Annotations

Attribute Purpose
[Table("Job", Schema = "irby")] Maps class to irby.Job table
[Key] Marks JobId as primary key
[Display(Name="JDE Number")] Friendly label for UI scaffolding
[NotMapped] Excludes property from EF mapping (calculated/runtime-only)

5. Property Reference Table 📋

Property Type Attributes Description
JobId Guid [Key] Unique identifier
JdeNumber string [Display] JDE external job number
Name string — Human‑readable job name
Employees ICollection — Assigned staff
SuperintendentId Guid? — FK to superintendent employee
ProjectEstimatorId Guid? — FK to estimator
ManagerId Guid? — FK to manager
Manager Employee [NotMapped] Loaded via separate query
ProjectEstimator Employee [NotMapped] Loaded via separate query
Superintendent Employee [NotMapped] Loaded via separate query
CustomerId Guid? — FK to customer
Customer Customer [NotMapped] Client info
JobType string — e.g. “Installation”, “Maintenance”
ContractType string — e.g. “Fixed Price”, “Time & Materials”
WorkType string — e.g. “Electrical”, “Civil”
GeoRegionCode string — Region code for reporting
GeoRegionDescription string — Human‑readable region
Status JobStatus (enum) — Current job lifecycle stage
RevenueDerivative string — e.g. “Revenue Recognition Method”
FieldOfficeId Guid? — FK to FieldOffice
FieldOffice FieldOffice [NotMapped] Office details
DatePlannedStart/Complete DateTime? — Scheduled dates
DateActualStart/Complete DateTime? — Realized dates
JobStatus string [NotMapped] Computed status text
SuperintendentName string — Denormalized full name for reporting
ProjectEstimatorName string — Denormalized full name
ManagerName string — Denormalized full name
CustomerName string — Denormalized client name
FieldOfficeName string — Denormalized office name
AddressLine1/2, City, … string — Job location
PostingEdit string — Misc. posting flags
SuretyDescription string — Bonding or surety details
PercentComplete string — e.g. “75%”
BudgetRequested, … decimal — Financial plan & changes

6. Usage Examples 💡

6.1 Creating a New Job

using IrbyImaging.DomainClasses;
using IrbyImaging.Utility;

var newJob = new Job
{
    JobId = Guid.NewGuid(),
    JdeNumber = "JDE-12345",
    Name = "Main Street Tower Installation",
    JobType = "Installation",
    ContractType = "Fixed Price",
    WorkType = "Electrical",
    
    // Budget & Dates
    BudgetRequested = 200_000m,
    BudgetApproved = 180_000m,
    DatePlannedStart = new DateTime(2022, 05, 01),
    DatePlannedComplete = new DateTime(2022, 09, 30),
    
    Status = JobStatus.Planned
};

6.2 Populating Navigation Properties

By default, [NotMapped] nav props are not auto‑loaded. You can load them explicitly:

// Assume _context is your DbContext:
var job = await _context.Jobs
    .FirstOrDefaultAsync(j => j.JobId == someId);

// Load the manager manually:
if (job.ManagerId.HasValue)
    job.Manager = await _context.Employees
        .FindAsync(job.ManagerId.Value);

7. Integration with EF Core & Query Samples 🛠️

// 1. Define DbContext
public class ImagingContext : DbContext
{
    public DbSet<Job> Jobs { get; set; }
    public DbSet<Employee> Employees { get; set; }
    // ...
}

// 2. Querying Jobs with Filters
var activeJobs = await context.Jobs
    .Where(j => j.Status == JobStatus.InProgress)
    .OrderBy(j => j.DatePlannedStart)
    .ToListAsync();

// 3. Include Related Entities (lightweight)
var detailedJobs = await context.Jobs
    .Select(j => new 
    {
        j.JobId,
        j.Name,
        Manager = context.Employees
                    .Where(e => e.EmployeeId == j.ManagerId)
                    .Select(e => e.FullName)
                    .FirstOrDefault(),
        j.BudgetApproved
    })
    .ToListAsync();

8. Conclusion & Next Steps ✅

🎯 Key Takeaways

  • Job.cs is a rich domain entity capturing the end‑to‑end lifecycle of a project.
  • DataAnnotations map fields to the irby.Job table seamlessly.
  • [NotMapped] props provide flexibility for runtime‑only or denormalized data.

🚀 Next Steps

  • Implement DTO/ViewModels for API surface and hide [NotMapped] internals.
  • Build CRUD services and controllers in your Web/API layer.
  • Extend validation (e.g. [Required], [Range]) for business rules.
  • Introduce AutoMapper profiles to map Job ↔ DTOs.

Thank you for exploring the Job.cs documentation! Feel free to reach out with questions or suggestions. 🙌