namespace App.Services.StateMachines
{
	using Contracts;
    using Contracts.DataModels;
    using Contracts.Services;
    using StateMachines;
    using System;
    using System.Collections.Generic;

    class DelegateStateMachine : BaseDelegateStateMachine, IDelegateStateMachine
    {
        public DelegateStateMachine(IDelegateService service):base(service)
        {}

        /// <summary>
        /// Tries the set the model to "start" state.
        /// </summary>
        public bool TrySetStart(int id, List<IModelError> errors, IModelContext context = null)
        {
            return TryUpdateItemState(id, DelegateTriggers.Start, errors, context);
        }

        /// <summary>
        /// Tries the set the model to "start" state.
        /// </summary>
        public bool TrySetStart(IDelegateDataModel model, List<IModelError> errors, IModelContext context = null)
        {
            return TryUpdateItemState(model, DelegateTriggers.Start, errors, context);
        }

        /// <summary>
        /// Tries the set the model to "complete" state.
        /// </summary>
        public bool TrySetComplete(int id, List<IModelError> errors, IModelContext context = null)
        {
            return TryUpdateItemState(id, DelegateTriggers.Complete, errors, context);
        }

        /// <summary>
        /// Tries the set the model to "complete" state.
        /// </summary>
        public bool TrySetComplete(IDelegateDataModel model, List<IModelError> errors, IModelContext context = null)
        {
            return TryUpdateItemState(model, DelegateTriggers.Complete, errors, context);
        }

        // Add new methods to represent other states //

        protected override DelegateStates ExtractState(IDelegateDataModel model)
        {
            // todo : extract a DelegateStates to repersent the current model
            throw new NotImplementedException();
        }

        protected override void SetModelState(DelegateStates state, IDelegateDataModel model)
        {
            // todo : update model properties to reflect the state
            throw new NotImplementedException();
        }
    }
}