using StammGenerator.Commands;
using StammGenerator.ViewModel;
using System.Threading.Tasks;

namespace StammGenerator.Commands
{
    internal class ProjektSelectCommand : AsyncCommandBase
    {
        private readonly IActualState _actualState;
        private readonly ProjektListViewModel _projektListViewModel;

        public ProjektSelectCommand(IActualState actualState, ProjektListViewModel projektListViewModel)
        {
            _actualState = actualState;
            _projektListViewModel = projektListViewModel;
        }

        public override async Task ExecuteAsync(object? parameter)
        {
            if (_projektListViewModel.SelectedProjekt == null) return;
            _actualState.SetProjekt(_projektListViewModel.SelectedProjekt);
        }
    }
}
