// EN: Kitchen ticket entity for kitchen display.
// VI: Entity KitchenTicket cho hiển thị bếp.

using FnbEngine.Domain.SeedWork;

namespace FnbEngine.Domain.AggregatesModel.KitchenAggregate;

/// <summary>
/// EN: Kitchen ticket entity - represents an order item in the kitchen.
/// VI: Entity KitchenTicket - đại diện cho item đơn hàng trong bếp.
/// </summary>
public class KitchenTicket : Entity, IAggregateRoot
{
    private Guid _sessionId;
    private Guid _orderItemId;
    private string _itemName = null!;
    private string? _station; // Bar, Kitchen, Grill, etc.
    private int _priority;
    private string _status = null!; // Pending, InProgress, Ready, Served
    private DateTime _createdAt;
    private DateTime? _completedAt;

    public Guid SessionId => _sessionId;
    public Guid OrderItemId => _orderItemId;
    public string ItemName => _itemName;
    public string? Station => _station;
    public int Priority => _priority;
    public string Status => _status;
    public DateTime CreatedAt => _createdAt;
    public DateTime? CompletedAt => _completedAt;

    protected KitchenTicket()
    {
    }

    public KitchenTicket(Guid sessionId, Guid orderItemId, string itemName, string? station = null, int priority = 0)
    {
        Id = Guid.NewGuid();
        _sessionId = sessionId;
        _orderItemId = orderItemId;
        _itemName = itemName;
        _station = station;
        _priority = priority;
        _status = "Pending";
        _createdAt = DateTime.UtcNow;
    }

    public void MarkAsInProgress()
    {
        _status = "InProgress";
    }

    public void MarkAsReady()
    {
        _status = "Ready";
        _completedAt = DateTime.UtcNow;
    }

    public void MarkAsServed()
    {
        _status = "Served";
    }
}
