using CartWise.Domain.Enums;

namespace CartWise.Domain.Entities;

public class HouseholdProductPreference
{
    public Guid HouseholdProductPreferenceId { get; private set; }

    public Guid HouseholdId { get; private set; }

    public Guid GroceryConceptId { get; private set; }

    public Guid? PreferredProductId { get; private set; }

    public SubstitutionLevel SubstitutionLevel { get; private set; }

    public decimal? PreferredQuantity { get; private set; }

    public string? PreferredUnit { get; private set; }

    public DateTime UpdatedUtc { get; private set; }

    private HouseholdProductPreference()
    {
    }

    public HouseholdProductPreference(
        Guid householdId,
        Guid groceryConceptId,
        SubstitutionLevel substitutionLevel,
        DateTime updatedUtc,
        Guid? preferredProductId = null,
        decimal? preferredQuantity = null,
        string? preferredUnit = null)
    {
        if (householdId == Guid.Empty)
        {
            throw new ArgumentException("HouseholdId is required.", nameof(householdId));
        }

        if (groceryConceptId == Guid.Empty)
        {
            throw new ArgumentException("GroceryConceptId is required.", nameof(groceryConceptId));
        }

        HouseholdProductPreferenceId = Guid.NewGuid();
        HouseholdId = householdId;
        GroceryConceptId = groceryConceptId;
        SubstitutionLevel = substitutionLevel;
        PreferredProductId = preferredProductId;
        PreferredQuantity = preferredQuantity;
        PreferredUnit = preferredUnit;
        UpdatedUtc = updatedUtc;
    }
}
