๐ MechanicTimesheet.cs Documentation
File Path:
IrbyImaging.DomainClasses/MechanicTimesheet.cs
Namespace:IrbyImaging.DomainClasses
๐ Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Entity: MechanicTimesheet
3.1. Data Annotations & ORM Mapping
3.2. Properties Breakdown - Enum: TimeSheetStatus
- UML Class Diagram
- Usage Examples
- Conclusion
๐ง Overview & Purpose
The MechanicTimesheet class represents a single timesheet entry for a mechanic in the Irby Imaging application. It is designed to be persisted in a relational database (via Entity Framework) within the irby.MechanicTimesheet table. Each record captures:
- Who worked on what job
- When they started and ended
- Regular vs. overtime hours
- Workflow status (draft, submitted, approved, etc.)
This domain class provides the data model for CRUD operations, reporting, and workflow management of mechanic timesheets.
๐ Dependencies & Technologies
| Technology | Version / Detail | Purpose |
|---|---|---|
| .NET (C#) | 6.0+ (or compatible) | Core application framework |
| Entity Framework | EF Core / EF 6.x | ORM for DB mapping |
| System.ComponentModel.DataAnnotations | Builtโin | Data validation and schema mapping |
| System.ComponentModel.DataAnnotations.Schema | Builtโin | Table & column configuration |
๐ Entity: MechanicTimesheet
namespace IrbyImaging.DomainClasses
{
[Table("MechanicTimesheet", Schema = "irby")]
public class MechanicTimesheet
{
[Key]
public Guid Id { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int TimesheetNumber { get; set; }
/* ... other properties ... */
public TimeSheetStatus Status { get; set; }
}
}
๐ Data Annotations & ORM Mapping
[Table("MechanicTimesheet", Schema = "irby")]
Maps this class to theirby.MechanicTimesheettable.[Key]
MarksIdas the primary key.[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
TimesheetNumberis an auto-incremented identity column.
๐ Properties Breakdown
| Property | Type | Description |
|---|---|---|
| Id | Guid |
Unique identifier (primary key). |
| TimesheetNumber | int |
Auto-generated timesheet reference number. |
| EmployeeId | Guid |
FK to the employee who logged the time. |
| EmployeeName | string |
Display name of the employee. |
| SubmittedBy | string |
Username or ID of the submitter. |
| StartTime | string |
Log entry start time (format: "HH:mm"). |
| EndTime | string |
Log entry end time (format: "HH:mm"). |
| StartDate | DateTime |
Date when the work began. |
| Job | string |
Job code or description. |
| PayCode | string |
Payroll code (e.g., regular, holiday). |
| CostType | string |
Cost center or billing type. |
| UnitNumber | string |
Vehicle or equipment number. |
| WorkOrderType | string |
Category of the work order. |
| WorkOrder | string |
Unique work order ID or reference. |
| Description | string |
Detailed work description. |
| RegularTime | string |
Hours worked at standard rate (format: "HH:mm"). |
| OverTime | string |
Hours worked at overtime rate (format: "HH:mm"). |
| Status | TimeSheetStatus |
Current workflow state. |
| RejectionComment | string |
Managerโs comments if the timesheet was rejected. |
| ReferenceNumber | int |
External reference (e.g., batch, invoice). |
| IsDeleted | bool |
Soft-delete flag. |
| ReviewedBy | string |
Username of the reviewer. |
| ApprovedBy | string |
Username of the approver. |
| ApprovedDate | DateTime |
Timestamp of final approval. |
๐ข Enum: TimeSheetStatus
public enum TimeSheetStatus
{
Draft,
Submitted,
Reviewed,
Approved,
Rejected
}
Meaning of States:
- Draft: Initial state, not yet sent for approval.
- Submitted: Sent to reviewer/manager.
- Reviewed: Reviewed but not yet approved.
- Approved: Final signโoff completed.
- Rejected: Sent back to the submitter for corrections.
๐ผ UML Class Diagram
@startuml
package IrbyImaging.DomainClasses {
class MechanicTimesheet {
+Guid Id
+int TimesheetNumber
+Guid EmployeeId
+string EmployeeName
+string SubmittedBy
+string StartTime
+string EndTime
+DateTime StartDate
+string Job
+string PayCode
+string CostType
+string UnitNumber
+string WorkOrderType
+string WorkOrder
+string Description
+string RegularTime
+string OverTime
+TimeSheetStatus Status
+string RejectionComment
+int ReferenceNumber
+bool IsDeleted
+string ReviewedBy
+string ApprovedBy
+DateTime ApprovedDate
}
enum TimeSheetStatus {
Draft
Submitted
Reviewed
Approved
Rejected
}
MechanicTimesheet --> TimeSheetStatus
}
@enduml
Note: To render the diagram, use a PlantUML viewer or extension.
๐ Usage Examples
1. Creating a New Timesheet
using IrbyImaging.DomainClasses;
// Instantiate a new timesheet
var timesheet = new MechanicTimesheet
{
EmployeeId = Guid.NewGuid(),
EmployeeName = "Jane Doe",
SubmittedBy = "jane.doe",
StartTime = "08:00",
EndTime = "17:00",
StartDate = DateTime.Today,
Job = "Brake Inspection",
PayCode = "REG",
CostType = "Internal",
UnitNumber = "VH-1023",
WorkOrderType = "Maintenance",
WorkOrder = "WO-2023-0456",
Description = "Replaced brake pads, test drove 20 miles.",
RegularTime = "08:00",
OverTime = "00:00",
Status = TimeSheetStatus.Submitted,
ReferenceNumber = 123456,
IsDeleted = false
};
2. Saving via Entity Framework
using (var context = new IrbyDbContext())
{
context.MechanicTimesheets.Add(timesheet);
await context.SaveChangesAsync();
}
3. Querying & Updating
// Retrieve
var ts = await context.MechanicTimesheets
.FirstOrDefaultAsync(t => t.TimesheetNumber == 1024);
// Update status
if (ts != null) {
ts.Status = TimeSheetStatus.Approved;
ts.ApprovedBy = "manager1";
ts.ApprovedDate = DateTime.Now;
await context.SaveChangesAsync();
}
๐ Conclusion
- MechanicTimesheet is the core domain entity for tracking mechanic labor entries.
- Built with Entity Framework in mind, leveraging data annotations for clean DB mapping.
- The TimeSheetStatus enum drives the workflow states.
- Easily extendedโadd new properties or integrate validation attributes as needed.
With this documentation, you now have a clear map of the structure, purpose, and usage patterns for the MechanicTimesheet class. Happy coding! ๐๐