📄 FieldLogEmployees.cs Documentation
Welcome to the IrbyImaging.DomainClasses documentation for FieldLogEmployees.cs. This file defines the core domain models used to track field timesheets for employees and equipment. Below you'll find a detailed overview, data models, class diagrams, sample usage, and more.
📑 Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- Data Models
4.1 FieldTimesheet
4.2 EmployeeTimesheet
4.3 WorkEntry
4.4 EquipmentTimesheet
4.5 EquipmentEntry
4.6 Status Enum - Class Diagram (Mermaid)
- Sample Usage & Code Snippets
- UML Diagram
- Conclusion
🧐 Overview & Purpose
The FieldLogEmployees.cs file provides the Domain Classes for managing:
- Field Timesheets (
FieldTimesheet) - Employee Timesheet Entries (
EmployeeTimesheet) - Work Entries (
WorkEntry) - Equipment Timesheet Entries (
EquipmentTimesheet) - Equipment Work Entries (
EquipmentEntry)
These classes form the root aggregate for a timesheet system, enabling you to:
- Record daily work entries per employee
- Track equipment usage and related metrics
- Manage lifecycle states (Draft → Submitted → Reviewed → Approved/Rejected)
🎯 Key Functional Areas
- FieldTimesheet
The root object representing a complete crew timesheet with metadata and status. - EmployeeTimesheet
Join-entity linking FieldTimesheet and Employee, with childWorkEntryrecords. - WorkEntry
Detailed per-day work log for an employee (hours, job codes, meals, etc.). - EquipmentTimesheet
Join-entity linking FieldTimesheet and Equipment, with childEquipmentEntrylogs. - EquipmentEntry
Daily equipment usage details (meter readings, idle/working hours). - Status Enum
Timesheet lifecycle states:Draft,Submitted,Reviewed,Approved,Rejected.
🔗 Dependencies & Technologies
- .NET Core / .NET Standard
- Entity Framework Core
System.ComponentModel.DataAnnotationsSystem.ComponentModel.DataAnnotations.Schema
- C# 8.0+ (for auto-properties & default values)
🗃 Data Models
Below is a breakdown of each class, its properties, and purpose.
1. FieldTimesheet
Table: irby.FieldTimesheet
Purpose: Root aggregate representing a crew’s daily or weekly timesheet.
[Table("FieldTimesheet", Schema = "irby")]
public class FieldTimesheet
{
[Key]
public Guid TimesheetId { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int TimesheetNumber { get; set; }
public string CrewId { get; set; }
public string ForemanSignature { get; set; }
public DateTime CreatedDate { get; set; } = DateTime.UtcNow;
public string Comments { get; set; }
public string SubmittedBy { get; set; }
public DateTime SubmittedDate { get; set; }
public string ReviewedBy { get; set; }
public DateTime ReviewedDate { get; set; }
public string ApprovedBy { get; set; }
public DateTime ApprovedDate { get; set; }
public bool IsDeleted { get; set; }
public Status Status { get; set; }
// Navigation properties
public List<EmployeeTimesheet> EmployeeTimesheets { get; set; }
public List<EquipmentTimesheet> EquipmentTimesheets { get; set; }
public List<Crew> Crews { get; set; }
}
| Property | Type | Attributes | Description |
|---|---|---|---|
| TimesheetId | Guid | [Key] |
Primary Key |
| TimesheetNumber | int | [DatabaseGenerated(Identity)] |
Auto-incremented timesheet number |
| CrewId | string | Identifier for the crew | |
| ForemanSignature | string | Signature of the crew foreman | |
| CreatedDate | DateTime | = DateTime.UtcNow |
Timestamp when created |
| Comments | string | Additional notes | |
| SubmittedBy/Date | string/DateTime | Submission metadata | |
| ReviewedBy/Date | string/DateTime | Review metadata | |
| ApprovedBy/Date | string/DateTime | Approval metadata | |
| IsDeleted | bool | Soft-delete flag | |
| Status | Status | Current workflow state | |
| EmployeeTimesheets | List<> | Child records for employees | |
| EquipmentTimesheets | List<> | Child records for equipment | |
| Crews | List | (Optional) Crew navigation |
2. EmployeeTimesheet
Table: irby.EmployeeTimesheet
Purpose: Bridge between FieldTimesheet and Employee, grouping that employee’s work entries.
[Table("EmployeeTimesheet", Schema = "irby")]
public class EmployeeTimesheet
{
[Key]
public Guid EmployeeTimesheetId { get; set; }
[ForeignKey("TimesheetId")]
public Guid TimesheetId { get; set; }
public FieldTimesheet Timesheet { get; set; }
[ForeignKey("EmployeeId")]
public Guid EmployeeId { get; set; }
public Employee Employee { get; set; }
public List<WorkEntry> WorkEntries { get; set; }
}
| Property | Type | Description |
|---|---|---|
| EmployeeTimesheetId | Guid | Primary Key |
| TimesheetId | Guid | FK to FieldTimesheet |
| Timesheet | FieldTimesheet | Navigation |
| EmployeeId | Guid | FK to Employee |
| Employee | Employee | Navigation |
| WorkEntries | List | Daily logs (see below) |
3. WorkEntry
Table: irby.WorkEntry
Purpose: Holds a single day’s worth of employee time & cost data.
[Table("WorkEntry", Schema = "irby")]
public class WorkEntry
{
[Key]
public Guid WorkEntryId { get; set; }
[Required]
public DateTime WorkDate { get; set; }
public string JobNo { get; set; }
public string CostCode { get; set; }
public string WorkOrder { get; set; }
public string Class { get; set; }
public string UnionCode { get; set; }
public string PayCode { get; set; }
public double RegularHours { get; set; }
public double OvertimeHours { get; set; }
public double DoubletimeHours { get; set; }
public string PerDiemType { get; set; }
public double PerDiemRate { get; set; }
public string JobTransfer { get; set; }
public bool Breakfast { get; set; }
public bool Lunch { get; set; }
public bool Dinner { get; set; }
public bool Motel { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public double LunchHour { get; set; }
public bool IsDeleted { get; set; }
[ForeignKey("EmployeeTimesheet")]
public Guid EmployeeTimesheetId { get; set; }
public EmployeeTimesheet EmployeeTimesheet { get; set; }
}
| Property | Type | Description |
|---|---|---|
| WorkEntryId | Guid | Primary Key |
| WorkDate | DateTime | Date of work (required) |
| JobNo / CostCode | string | Project & cost allocation |
| WorkOrder / Class | string | Additional classifications |
| UnionCode / PayCode | string | Payroll details |
| Regular/Overtime/DoubletimeHours | double | Hour breakdown |
| PerDiemType/Rate | string/double | Meal allowances |
| JobTransfer | string | Transfer notes |
| Meals & Motel flags | bool | Expense eligibility |
| StartTime / EndTime | string | Clock in/out (HH:mm) |
| LunchHour | double | Lunch break duration |
| IsDeleted | bool | Soft-delete |
| EmployeeTimesheetId | Guid | FK to EmployeeTimesheet |
4. EquipmentTimesheet
Table: irby.EquipmentTimesheet
Purpose: Bridge between FieldTimesheet and Equipment, grouping that equipment’s daily logs.
[Table("EquipmentTimesheet", Schema = "irby")]
public class EquipmentTimesheet
{
[Key]
public Guid EquipmentTimesheetId { get; set; }
[ForeignKey("FieldTimesheet")]
public Guid TimesheetId { get; set; }
public FieldTimesheet Timesheet { get; set; }
[ForeignKey("Equipment")]
public Guid EquipmentId { get; set; }
public Equipment Equipment { get; set; }
public List<EquipmentEntry> EquipmentEntries { get; set; }
}
| Property | Type | Description |
|---|---|---|
| EquipmentTimesheetId | Guid | Primary Key |
| TimesheetId | Guid | FK to FieldTimesheet |
| Timesheet | FieldTimesheet | Navigation |
| EquipmentId | Guid | FK to Equipment |
| Equipment | Equipment | Navigation |
| EquipmentEntries | List | Child equipment logs |
5. EquipmentEntry
Table: irby.EquipmentEntry
Purpose: Daily usage and meter readings for a piece of equipment.
[Table("EquipmentEntry", Schema = "irby")]
public class EquipmentEntry
{
[Key]
public Guid EquipmentEntryId { get; set; }
public double OdometerReading { get; set; }
public double Meter { get; set; }
public string CostCode { get; set; }
public string JobNo { get; set; }
public double WorkedHours { get; set; }
public double IdleHours { get; set; }
public DateTime WorkDate { get; set; }
[ForeignKey("EquipmentTimesheet")]
public Guid EquipmentTimesheetId { get; set; }
public EquipmentTimesheet EquipmentTimesheet { get; set; }
}
| Property | Type | Description |
|---|---|---|
| EquipmentEntryId | Guid | Primary Key |
| OdometerReading | double | Vehicle odometer reading |
| Meter | double | Equipment meter reading |
| CostCode / JobNo | string | Project allocation |
| WorkedHours / IdleHours | double | Usage breakdown |
| WorkDate | DateTime | Entry date |
| EquipmentTimesheetId | Guid | FK to EquipmentTimesheet |
6. Status Enum
public enum Status
{
Draft,
Submitted,
Reviewed,
Approved,
Rejected
}
| Member | Description |
|---|---|
| Draft | Initial state before submission |
| Submitted | Sent for review |
| Reviewed | Undergoing review |
| Approved | Finalized & approved |
| Rejected | Sent back for corrections |
📊 Class Diagram (Mermaid)
classDiagram
FieldTimesheet "1" o-- "*" EmployeeTimesheet : employees
FieldTimesheet "1" o-- "*" EquipmentTimesheet : equipment
EmployeeTimesheet "1" o-- "*" WorkEntry : workEntries
EquipmentTimesheet "1" o-- "*" EquipmentEntry : equipmentEntries
class FieldTimesheet {
+Guid TimesheetId
+int TimesheetNumber
+string CrewId
+string ForemanSignature
+DateTime CreatedDate
+Status Status
+bool IsDeleted
}
class EmployeeTimesheet {
+Guid EmployeeTimesheetId
+Guid TimesheetId
+Guid EmployeeId
}
class WorkEntry {
+Guid WorkEntryId
+DateTime WorkDate
+double RegularHours
+double OvertimeHours
+bool IsDeleted
}
class EquipmentTimesheet {
+Guid EquipmentTimesheetId
+Guid TimesheetId
+Guid EquipmentId
}
class EquipmentEntry {
+Guid EquipmentEntryId
+DateTime WorkDate
+double WorkedHours
+double IdleHours
}
🛠 Sample Usage & Code Snippets
Below is a basic example showing how to create, populate, and persist a timesheet:
using (var context = new IrbyContext())
{
// 1. Create a new timesheet
var timesheet = new FieldTimesheet
{
CrewId = "Crew-Alpha",
ForemanSignature = "Jane Doe",
Comments = "All good for the week",
Status = Status.Draft
};
// 2. Add an employee with work entries
var empTimesheet = new EmployeeTimesheet
{
EmployeeId = Guid.Parse("a1b2c3d4-e5f6-7890-abcd-1234567890ab"),
Timesheet = timesheet,
WorkEntries = new List<WorkEntry>
{
new WorkEntry
{
WorkDate = DateTime.Today,
JobNo = "J1001",
CostCode = "C200",
RegularHours = 8,
OvertimeHours = 2,
StartTime = "08:00",
EndTime = "18:00",
Breakfast = true,
Lunch = true,
Motel = false
}
}
};
// 3. Add equipment usage
var eqTimesheet = new EquipmentTimesheet
{
EquipmentId = Guid.Parse("e1f2g3h4-i5j6-7890-klmn-0987654321po"),
Timesheet = timesheet,
EquipmentEntries = new List<EquipmentEntry>
{
new EquipmentEntry
{
WorkDate = DateTime.Today,
OdometerReading = 10245.6,
Meter = 128.4,
WorkedHours = 10,
IdleHours = 1
}
}
};
// 4. Attach to context & save
timesheet.EmployeeTimesheets = new List<EmployeeTimesheet> { empTimesheet };
timesheet.EquipmentTimesheets = new List<EquipmentTimesheet> { eqTimesheet };
context.FieldTimesheets.Add(timesheet);
context.SaveChanges();
}
📈 UML Diagram
@startuml
class FieldTimesheet {
+Guid TimesheetId
+int TimesheetNumber
+string CrewId
+Status Status
}
class EmployeeTimesheet {
+Guid EmployeeTimesheetId
}
class WorkEntry {
+Guid WorkEntryId
+double RegularHours
}
class EquipmentTimesheet {
+Guid EquipmentTimesheetId
}
class EquipmentEntry {
+Guid EquipmentEntryId
+double WorkedHours
}
FieldTimesheet --|> EmployeeTimesheet
EmployeeTimesheet --|> WorkEntry
FieldTimesheet --|> EquipmentTimesheet
EquipmentTimesheet --|> EquipmentEntry
@enduml
✅ Conclusion
This file encapsulates the domain layer for field timesheet management:
- A root aggregate (
FieldTimesheet) to coordinate employee and equipment records - Join entities to represent many‐to‐many relationships
- Detailed entry classes (
WorkEntry,EquipmentEntry) capturing hours, costs, and usage - A Status enum guiding the workflow
With these models, you can easily build services or APIs to create, update, review, and approve field timesheets—ensuring robust tracking of both labor and equipment in your application. 🚀
Happy coding! ✨