using eSuite.WorkBench.Services;
using eSuite.WorkBench.WpfHelper;
using System;
using System.Threading.Tasks;

namespace eSuite.WorkBench.Commands
{
    public class DeleteDatabaseCommand : AsyncCommandBase
    {
        private readonly IMainWindowViewModel _mainWindowViewModel;
        private readonly IDbService _dbService;

        public DeleteDatabaseCommand(IMainWindowViewModel mainWindowViewModel, IDbService dbService, Action<Exception> onException, EventHandler<FeedbackEventArgs> addFeedbackMessage) : base(onException)
        {
            FeedbackMessage += addFeedbackMessage;
            _mainWindowViewModel = mainWindowViewModel;
            _dbService = dbService;
        }

        protected override async Task ExecuteAsync(object parameter)
        {
            DoFeedbackMessage("Deleting database...");
            await _dbService.DropDatabaseAsync();
            DoFeedbackMessage("...database deleted");
        }
    }
}
