using e_suite.Workflow.Core.Enums;

namespace e_suite.Workflow.Core.Interfaces;

public interface ITask
{ 
    /// <summary>
    /// The guid identifying this task.
    /// </summary>
    Guid Guid { get; set; }

    /// <summary>
    /// ID of the parent of this task.  It could be either a Task or a Workflow.
    /// </summary>
    ITask Parent { get; }


    //Todo move this out to runtime only.
    /// <summary>
    /// Current state of the Task.
    /// </summary>
    TaskState TaskState { get; set; }

    /// <summary>
    /// Name of the task as seen by users, must be unique in the workflow.
    /// </summary>
    string Name { get; set; }

    /// <summary>
    /// Description of the task
    /// </summary>
    string Description { get; set; }

    /// <summary>
    /// List of tasks that need to be completed before this on can start.  (If empty, will start when the workflow starts)
    /// </summary>
    IList<ITask> Predecessors { get; }

    /// <summary>
    /// units of work involved in this item (UoW is a business term in this context)
    /// </summary>
    public decimal UnitsOfWork { get; set; }

    /// <summary>
    /// Cost of this work item
    /// </summary>
    public Cost Cost { get; set; }

    /// <summary>
    /// The option to show in budget.
    /// </summary>
    public BudgetOption BudgetOption { get; set; }

    /// <summary>
    /// Time tracking of this item
    /// </summary>
    public bool AllowTimeTracking { get; set; }

    /// <summary>
    /// Priority of this item
    /// </summary>
    public Priority Priority { get; set; }
    
    /// <summary>
    /// alloted duration of this item.
    /// </summary>
    public TimeSpan Duration { get; set; }
    
    public IList<string> Tags { get; set; }

    /// <summary>
    /// Called when the task status has been progressed from Pending to Active.
    ///
    /// Note: You can use this method to set the TaskStatus to ReadyToComplete if there is no manual processing needed for this task.
    /// After this method is completed, the TaskStatus must be either Active or ReadyToComplete.
    /// </summary>
    /// <returns></returns>
    Task OnActivateAsync();

    /// <summary>
    /// Called when the task status has been progressed from ReadyToComplete to Completed
    /// </summary>
    /// <returns>True when the task completes successfully, false when it is considered failed.</returns>
    Task<bool> OnCompleteAsync();

    //Todo add support for events (soap, rest, sftp, e-mail)
}