using System;
using System.ComponentModel.DataAnnotations;
namespace trakker.Models
{
///
/// Represents a client record in the application.
/// Contains contact information, address fields, and audit timestamps.
/// Validation attributes decorate properties to enforce basic constraints.
///
public class Client
{
///
/// Primary identifier for the client. This maps to the database client_id.
/// Marked with to indicate the primary key.
///
[Key]
public string ClientId { get; set; } = Guid.NewGuid().ToString();
///
/// The client's full name. This field is required and has a maximum length of 200 characters.
///
[Required]
[MaxLength(200)]
public string Name { get; set; } = string.Empty;
///
/// Optional company name associated with the client. Maximum length 200 characters.
///
[MaxLength(200)]
public string? Company { get; set; } = string.Empty;
///
/// Optional email address for the client. Validated with and
/// constrained to 255 characters.
///
[EmailAddress]
[MaxLength(255)]
public string? Email { get; set; } = string.Empty;
///
/// Optional phone number for the client. Validated with and
/// constrained to 50 characters.
///
[Phone]
[MaxLength(50)]
public string? Phone { get; set; } = string.Empty;
///
/// Street address for the client. Optional and limited to 100 characters.
///
[MaxLength(100)]
public string? AddressStreet { get; set; } = string.Empty;
///
/// City portion of the client's address. Optional and limited to 100 characters.
///
[MaxLength(100)]
public string? AddressCity { get; set; } = string.Empty;
///
/// State portion of the client's address. Stored as a 2-character code (e.g., US state abbreviation).
///
[MaxLength(2)]
public string? AddressState { get; set; } = string.Empty;
///
/// Postal code portion of the client's address. Limited to 5 characters in this model.
///
[MaxLength(5)]
public string? AddressPostal { get; set; } = string.Empty;
///
/// Free-form notes about the client. Optional and limited to 2000 characters.
///
[MaxLength(2000)]
public string? Notes { get; set; } = string.Empty;
///
/// Indicates whether the client is active. Defaults to true.
///
public string IsActive { get; set; } = "y";
///
/// UTC timestamp for when the record was created. Defaults to .
///
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
///
/// UTC timestamp for when the record was last updated. Updated by application code
/// when changes are made.
///
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
///
/// Updates the timestamp to the current UTC time. Call this
/// before persisting changes to ensure the audit timestamp is accurate.
///
public int ProjectCount { get; set; } = 0;
public void UpdateTimestamp()
{
UpdatedAt = DateTime.UtcNow;
}
}
}