using System;
using System.Windows.Input;
using Valg.EVA.Skanning.ServicesModel.ServiceContracts.Count.Read;
using Prism.Commands;
using Valg.Eva.Skanning.Scan.Presentation.MainWindow;
using Valg.EVA.Skanning.UserInterfaceElements;

namespace Valg.Eva.Skanning.Scan.Presentation.SelectCountingUnitPopup
{
    public class SelectCountingUnitViewModel : ViewModelBase
    {
        private readonly Action<ScannableCounting> onComplete;

        public SelectCountingUnitViewModel(CountingUnitCollection units, Action<ScannableCounting> onComplete)
        {
            this.onComplete = onComplete;
            CountingUnits = units;
            SelectCountingUnitCommand = new DelegateCommand<ScannableCounting>(SelectCountingUnit);
        }

        private void SelectCountingUnit(ScannableCounting counting)
        {
            onComplete(counting);
        }

        public CountingUnitCollection CountingUnits { get; private set; }
        public ScannableCounting FirstCounting { get { return CountingUnits.FirstCounting; } }
        public ScannableCounting SecondCounting { get { return CountingUnits.SecondCounting; } }

        public ICommand SelectCountingUnitCommand { get; private set; }
    }
}

