﻿using System;
using System.Windows;
using System.Windows.Input;
using Jacuzzi.ViewModels;

namespace Jacuzzi.Commands
{
    public class DeleteProjectCommand:ICommand
    {
        private readonly MainViewModel _viewModel;

        public DeleteProjectCommand(MainViewModel viewModel)
        {
            _viewModel = viewModel;
        }

        public void Execute(object parameter)
        {
            //todo
            var result = MessageBox.Show("Удалить проект " + _viewModel.CurrentProject.Name + "?","Удалить проект", MessageBoxButton.YesNo);
            if (result==MessageBoxResult.Yes)
            {
                _viewModel.Projects.Remove(_viewModel.CurrentProject);
                _viewModel.CurrentProject = null;
            }
        }

        public bool CanExecute(object parameter)
        {
            return _viewModel.CurrentProject != null;
        }

        public event EventHandler CanExecuteChanged;
    }
}