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

namespace LittleShop.Models;

public class ProductVariation
{
    [Key]
    public Guid Id { get; set; }

    public Guid ProductId { get; set; }

    [Required]
    [StringLength(100)]
    public string Name { get; set; } = string.Empty; // e.g., "Single Item", "Twin Pack", "Triple Pack"

    public string Description { get; set; } = string.Empty; // e.g., "Best value for 3 items"

    public int Quantity { get; set; } // The quantity this variation represents (1, 2, 3, etc.)

    [Column(TypeName = "decimal(18,2)")]
    public decimal Price { get; set; } // The price for this quantity (£10, £19, £25)

    [Column(TypeName = "decimal(18,2)")]
    public decimal PricePerUnit { get; set; } // Calculated: Price / Quantity (for easy comparison)

    public int SortOrder { get; set; } = 0; // For controlling display order

    public bool IsActive { get; set; } = true;

    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

    // Navigation properties
    public virtual Product Product { get; set; } = null!;
    public virtual ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
}