📑 TimeEntryType Domain Model Documentation


🚀 Table of Contents

  1. 🌟 Overview & Purpose
  2. 🏗️ Key Functional Areas
  3. 📦 Dependencies & Technologies
  4. 🗂️ Data Model Details
  5. 🦄 UML Class Diagram
  6. 🔧 Sample Code Blocks
  7. 📘 Usage Examples
  8. 🚦 Error Handling & Return Types
  9. 🛠️ Third-Party Integrations
  10. 🏁 Conclusion

🌟 Overview & Purpose

The TimeEntryType class is a Domain Model that represents a type or category of time entry within the Irby Imaging system. Typical use-cases include:

  • Distinguishing between Development, Testing, Support, etc.
  • Auditing who created or last modified the entry type.
  • Soft-deletion support to hide obsolete types without losing historical data.

It maps directly to the SQL table irby.TimeEntryType via Entity Framework attributes.


🏗️ Key Functional Areas

  • Data Mapping
    Uses EF attributes to map CLR properties to database columns/table.
  • Auditing
    Tracks AddedBy, AddedDate, ModifiedBy, ModifiedDate.
  • Soft Deletion
    The IsDeleted flag enables safe, reversible deletion.
  • GUID PK
    Uses globally unique ID for robust cross-system identification.

📦 Dependencies & Technologies

Technology / NuGet Package Purpose
Microsoft.EntityFrameworkCore ORM for mapping & queries
System.ComponentModel.DataAnnotations Data annotations & validation
.NET Standard / .NET Core (any) Cross-platform runtime

🗂️ Data Model Details

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace IrbyImaging.DomainClasses
{
    [Table("TimeEntryType", Schema = "irby")]
    public class TimeEntryType
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public Guid TimeEntryTypeId { get; set; }
        
        public string Name { get; set; }
        
        public bool IsDeleted { get; set; }
        
        public string AddedBy { get; set; }
        
        public DateTime AddedDate { get; set; }
        
        public string ModifiedBy { get; set; }
        
        public DateTime ModifiedDate { get; set; }
    }
}

🔍 Property Breakdown

Property Type Attributes Description
TimeEntryTypeId Guid [Key], [DatabaseGenerated(None)] Primary Key (no auto-generation)
Name string – Descriptive name of the time entry type
IsDeleted bool – Soft-delete flag; true = hidden/inactive
AddedBy string – User who created the record
AddedDate DateTime – Timestamp of record creation
ModifiedBy string – User who last modified the record
ModifiedDate DateTime – Timestamp of last modification

🦄 UML Class Diagram

classDiagram
    class TimeEntryType {
        <<Entity>>
        +Guid TimeEntryTypeId
        +string Name
        +bool IsDeleted
        +string AddedBy
        +DateTime AddedDate
        +string ModifiedBy
        +DateTime ModifiedDate
    }
    note for TimeEntryType "Maps to irby.TimeEntryType table"

🔧 Sample Code Blocks

1. Defining the DbContext

public class IrbyDbContext : DbContext
{
    public DbSet<TimeEntryType> TimeEntryTypes { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // Apply configurations if any
        base.OnModelCreating(modelBuilder);
    }
}

2. Seeding Initial Data

modelBuilder.Entity<TimeEntryType>().HasData(
    new TimeEntryType {
        TimeEntryTypeId = Guid.Parse("11111111-2222-3333-4444-555555555555"),
        Name = "Development",
        IsDeleted = false,
        AddedBy = "system",
        AddedDate = DateTime.UtcNow,
        ModifiedBy = "system",
        ModifiedDate = DateTime.UtcNow
    },
    new TimeEntryType {
        TimeEntryTypeId = Guid.Parse("66666666-7777-8888-9999-000000000000"),
        Name = "Support",
        IsDeleted = false,
        AddedBy = "system",
        AddedDate = DateTime.UtcNow,
        ModifiedBy = "system",
        ModifiedDate = DateTime.UtcNow
    }
);

📘 Usage Examples

Adding a New TimeEntryType

using(var context = new IrbyDbContext())
{
    var newType = new TimeEntryType {
        TimeEntryTypeId = Guid.NewGuid(),
        Name           = "Testing",
        IsDeleted      = false,
        AddedBy        = "jane.doe",
        AddedDate      = DateTime.UtcNow,
        ModifiedBy     = "jane.doe",
        ModifiedDate   = DateTime.UtcNow
    };
    context.TimeEntryTypes.Add(newType);
    context.SaveChanges();
}

Querying Active Types

using(var context = new IrbyDbContext())
{
    var activeTypes = context.TimeEntryTypes
                            .Where(t => !t.IsDeleted)
                            .OrderBy(t => t.Name)
                            .ToList();
    
    foreach(var t in activeTypes)
    {
        Console.WriteLine($"{t.Name} ({t.TimeEntryTypeId})");
    }
}

🚦 Error Handling & Return Types

  • Creation Errors
    • Duplicate TimeEntryTypeId: throws DbUpdateException.
    • Null or empty Name: could violate application-level validations.
  • Query Errors
    • Invalid LINQ filters: thrown at runtime.
  • Soft-Deletion
    • Toggling IsDeleted avoids hard deletes, preserving history.

🛠️ Third-Party Integrations

  • Entity Framework Core
    • Core ORM for mapping, migrations, and change tracking.
  • Database
    • Any EF Core provider (SQL Server, PostgreSQL, etc.) supporting schemas.

🏁 Conclusion

The TimeEntryType class is a simple yet powerful domain entity that provides:

  • Categorization of time entries.
  • Audit trails for creation and modification.
  • Soft-deletion for non-destructive data lifecycle management.

Use it in conjunction with Entity Framework Core to ensure your application has a robust, auditable, and extensible foundation for managing time-entry categories.

👉 Next Steps:

  • Integrate with your service layer, expose via Web API / GraphQL.
  • Implement view models or DTOs for safe client-side usage.
  • Add business logic or validation attributes as needed for your domain rules.

Happy coding! 🎉