using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using GalaSoft.MvvmLight.Command;

namespace EventTrigger_ConfirmationMessage
{
	public class MyViewModel 
	{
		public event PropertyChangedEventHandler PropertyChanged;

		private ObservableCollection<Club> clubs;

		private RelayCommand<object> _deleteCustomerOrderCommand;
		public RelayCommand<object> DeleteCustomerOrderCommand
		{
			get
			{
				if (_deleteCustomerOrderCommand == null)
				{
					_deleteCustomerOrderCommand = new RelayCommand<object>(param => this.DeleteCustomerOrder(param), param => this.CanDeleteCustomerOrder());
				}
				return _deleteCustomerOrderCommand;
			}
		}
		private void DeleteCustomerOrder(object obj)
		{
			this.Clubs.Remove(obj as Club);
		}
		private bool CanDeleteCustomerOrder()
		{
			string messageBoxText = "Are you sure you want to delete the selected Orders?";
			string caption = "Confirm";
			MessageBoxButton button = MessageBoxButton.YesNo;
			MessageBoxImage icon = MessageBoxImage.Question;
			MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon);

			if (result == MessageBoxResult.Yes)
			{
				return true;
			}
			else
			{
				return false;
			}				
		}

		public ObservableCollection<Club> Clubs
		{
			get
			{
				if (this.clubs == null)
				{
					this.clubs = Club.GetClubs();
				}

				return this.clubs;
			}
		}		
	}
}
