๐Ÿ“„ MechanicTimesheet.cs Documentation

File Path: IrbyImaging.DomainClasses/MechanicTimesheet.cs
Namespace: IrbyImaging.DomainClasses


๐Ÿ“‹ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Entity: MechanicTimesheet
    3.1. Data Annotations & ORM Mapping
    3.2. Properties Breakdown
  4. Enum: TimeSheetStatus
  5. UML Class Diagram
  6. Usage Examples
  7. 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 the irby.MechanicTimesheet table.
  • [Key]
    Marks Id as the primary key.
  • [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    TimesheetNumber is 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! ๐Ÿš€๐ŸŽ‰