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

namespace eSuite.WorkBench.Commands
{
    public class BackupDatabaseCommand : AsyncCommandBase
    {
        private readonly IDbService _dbService;

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

        protected override async Task ExecuteAsync(object parameter)
        {
            DoFeedbackMessage("Backing up database...");
            await _dbService.BackupDatabaseAsync();
            DoFeedbackMessage("...database backed up");
        }
    }
}
