using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace RadTreeListView_ComboBoxColumn_WPF
{
	/// <summary>
	/// A football player.
	/// </summary>
	public class Player : INotifyPropertyChanged
	{
		public event PropertyChangedEventHandler PropertyChanged;

		private string name;
		private int countryID;

		public string Name
		{
			get { return this.name; }
			set
			{
				if (value != this.name)
				{
					this.name = value;
					this.OnPropertyChanged("Name");
				}
			}
		}

		public int CountryID
		{
			get { return this.countryID; }
			set
			{
				if (value != this.countryID)
				{
					this.countryID = value;
					this.OnPropertyChanged("CountryID");
				}
			}
		}

		
		public Player()
		{

		}

		public Player(string name, int countryID)
		{
			this.name = name;
			this.countryID = countryID;
		}

		protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
		{
			PropertyChangedEventHandler handler = this.PropertyChanged;
			if (handler != null)
			{
				handler(this, args);
			}
		}

		private void OnPropertyChanged(string propertyName)
		{
			this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
		}

		public override string ToString()
		{
			return this.Name;
		}

		public static ObservableCollection<Player> GetPlayers()
		{
			return new ObservableCollection<Player>(Club.GetClubs().SelectMany(c => c.Players));
		}
	}
}
