using System;
using System.Collections.Generic;
using System.Text;

namespace InABox.Core
{
    public enum PostedStatus
    {
        NeverPosted,
        PostFailed,
        RequiresRepost,
        Posted
    }

    /// <summary>
    /// Flags an <see cref="Entity"/> as "Postable"; that is, it can be processed by an <see cref="IPoster{TEntity,TSettings}"/>.
    /// </summary>
    public interface IPostable : IPostableFragment
    {
        /// <summary>
        /// At what time this <see cref="IPostable"/> was processed. Set to <see cref="DateTime.MinValue"/> if not processed yet.
        /// When the <see cref="IPostable"/> is processed, this should be updated, so that we don't process things twice.
        /// </summary>
        DateTime Posted { get; set; }

        PostedStatus PostedStatus { get; set; }

        string PostedNote { get; set; }

        public void Post()
        {
            Posted = DateTime.Now;
            PostedStatus = PostedStatus.Posted;
            PostedNote = "";
        }

        public void FailPost(string note)
        {
            Posted = DateTime.Now;
            PostedStatus = PostedStatus.PostFailed;
            PostedNote = note;
        }
    }
}
