using Valg.EVA.Skanning.Contracts.CommonEnums;
using ReactiveUI;

namespace Valg.EVA.Skanning.JobManagement.Startup.Data.Transfer
{
    public class CountingCompleteModel : ReactiveObject
    {
        private CountingModel counting;
        public CountingModel Counting
        {
            get { return counting; }
            set { this.RaiseAndSetIfChanged(ref counting, value); }
        }

        private TransferModel transfer;
        public TransferModel Transfer
        {
            get { return transfer; }
            set { this.RaiseAndSetIfChanged(ref transfer, value); }
        }

        public TransferState State
        {
            get { return transfer.State; }
        }

        public string ErrorCode
        {
            get { return transfer.ErrorCode; }
        }

        public bool CheckStatusForTransferManually
        {
            get { return transfer.CheckStatusForTransferManually; }
        }

        public CountingCompleteModel(CountingModel counting, TransferModel transfer)
        {
            this.counting = counting;
            this.transfer = transfer;

            if (transfer != null)
            {
                transfer.Bubble(
                    from => from.State,
                    this,
                    to => to.State);
                transfer.Bubble(
                    from => from.ErrorCode,
                    this,
                    to => to.ErrorCode);
                transfer.Bubble(
                    from => from.CheckStatusForTransferManually,
                    this,
                    to => to.CheckStatusForTransferManually);
            }
        }

    }
}
