56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace trakker.Models
|
|
{
|
|
public class TimeEntry
|
|
{
|
|
[Key]
|
|
public string EntryId { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string ProjectId { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string ClientId { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public DateOnly WorkDate { get; set; }
|
|
|
|
public TimeOnly? StartTime { get; set; }
|
|
|
|
public TimeOnly? EndTime { get; set; }
|
|
|
|
[Required]
|
|
[Range(0.01, double.MaxValue)]
|
|
public decimal Hours { get; set; }
|
|
|
|
[MaxLength(1000)]
|
|
public string? Description { get; set; }
|
|
|
|
[Range(0, double.MaxValue)]
|
|
public decimal? Rate { get; set; }
|
|
|
|
// Computed column (mirrors the GENERATED ALWAYS AS clause)
|
|
public decimal Amount => (Rate ?? 0) * Hours;
|
|
|
|
public bool Billed { get; set; } = false;
|
|
|
|
public DateOnly? BilledDate { get; set; }
|
|
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
// Optional navigation properties (great for EF Core)
|
|
public Project? Project { get; set; }
|
|
public Client? Client { get; set; }
|
|
|
|
// Helper method
|
|
public void UpdateTimestamp()
|
|
{
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
}
|
|
}
|