using StammGenerator.Commands;
using StammGenerator.Enum;
using StammGenerator.Interface;
using System.Threading.Tasks;

namespace StammGenerator.Commands
{
    internal class UpdateCurrentViewModelCommand : AsyncCommandBase
    {
        private INavigator _navigator;
        private readonly IViewModelAbstractFactory _viewModelFactory;

        public UpdateCurrentViewModelCommand(INavigator navigator, IViewModelAbstractFactory viewModelFactory)
        {
            _navigator = navigator;
            _viewModelFactory = viewModelFactory;
        }

        public override async Task ExecuteAsync(object? parameter)
        {
            if(parameter is EMainWindowViewType)
            {
                EMainWindowViewType viewType = (EMainWindowViewType)parameter;
                _navigator.CurrentViewModel = _viewModelFactory.CreateViewModel(viewType);
            }
        }
    }
}
