using System;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace Sched.CustomClasses
{
    public class Teacher: INotifyPropertyChanged
    {
        private int _id;
        private string _firstName;
        private string _lastName;
        private string _ranks;

        public int Id
        {
            get { return _id; }
            set { _id = value; OnPropertyChanged("Id"); }
        }
        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = value; OnPropertyChanged("FirstName"); }
        }
        public string LastName
        {
            get { return _lastName; }
            set { _lastName = value; OnPropertyChanged("LastName"); }
        }
        public string Ranks
        {
            get { return _ranks; }
            set { _ranks = value; OnPropertyChanged("Ranks"); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string info)
        {
            var handler = PropertyChanged;
            handler?.Invoke(this, new PropertyChangedEventArgs(info));
        }

        public Teacher()    //A blank constructor must exist to enable creating a blank row in DataGrid
        {
            this.Id = 0;
            this.FirstName = string.Empty;
            this.LastName = string.Empty;
            this.Ranks = string.Empty;
        }

        public override string ToString()
        {
            string ranks = _ranks;
            if (ranks.Length > 0)
            {
                ranks = ", " + ranks;
            }

            return $"{_lastName} {_firstName}{ranks} ({_id})";
        }
    }
}
