93 lines
2.4 KiB
C#
93 lines
2.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Lagerbestand.Models;
|
|
|
|
/// <summary>
|
|
/// Represents a vehicle owned by a customer.
|
|
/// A customer can have multiple vehicles, each with their own tire stacks.
|
|
/// </summary>
|
|
public class Vehicle
|
|
{
|
|
[Key]
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
|
|
|
/// <summary>
|
|
/// The customer who owns this vehicle
|
|
/// </summary>
|
|
public Guid CustomerId { get; set; }
|
|
|
|
[ForeignKey(nameof(CustomerId))]
|
|
public Customer? Customer { get; set; }
|
|
|
|
/// <summary>
|
|
/// Vehicle manufacturer (e.g., "BMW", "Mercedes", "VW")
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(100)]
|
|
public string Make { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Vehicle model (e.g., "3er", "C-Klasse", "Golf")
|
|
/// </summary>
|
|
[MaxLength(100)]
|
|
public string? Model { get; set; }
|
|
|
|
/// <summary>
|
|
/// Tire size for this vehicle (e.g., "225/45 R17")
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(50)]
|
|
public string TireSize { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Additional notes about the vehicle
|
|
/// </summary>
|
|
[MaxLength(500)]
|
|
public string? Notes { get; set; }
|
|
|
|
/// <summary>
|
|
/// Whether this is the customer's primary/default vehicle
|
|
/// </summary>
|
|
public bool IsPrimary { get; set; }
|
|
|
|
/// <summary>
|
|
/// Whether the vehicle is active (not deleted)
|
|
/// </summary>
|
|
public bool IsActive { get; set; } = true;
|
|
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
public DateTime? UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Navigation property for tire stacks stored for this vehicle
|
|
/// </summary>
|
|
public ICollection<TireStack> TireStacks { get; set; } = new List<TireStack>();
|
|
|
|
/// <summary>
|
|
/// Display name combining make, model, and tire size
|
|
/// </summary>
|
|
[NotMapped]
|
|
public string DisplayName
|
|
{
|
|
get
|
|
{
|
|
var name = Make;
|
|
if (!string.IsNullOrEmpty(Model))
|
|
name += $" {Model}";
|
|
if (!string.IsNullOrEmpty(TireSize))
|
|
name += $" ({TireSize})";
|
|
return name;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Short display showing just make (for compact views)
|
|
/// </summary>
|
|
[NotMapped]
|
|
public string ShortName => !string.IsNullOrEmpty(Model)
|
|
? $"{Make} {Model}"
|
|
: Make;
|
|
}
|