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

namespace Sched.CustomClasses
{
    public class Course: INotifyPropertyChanged
    {
        private int _id = 0;
        private string _abbreviation = string.Empty;
        private string _name = string.Empty;

        public int Id
        {
            get { return _id; }
            set { _id = value; OnPropertyChanged("Id"); }
        }
        public string Abbreviation
        {
            get { return _abbreviation; }
            set { _abbreviation = value; OnPropertyChanged("Abbreviation"); }
        }
        public string Name
        {
            get { return _name; }
            set { _name = value; OnPropertyChanged("Name"); }
        }

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

        public Course()
        {
        }
        public Course(int Id, string Abbreviation, string Name)
        {
            this.Id = Id;
            this.Abbreviation = Abbreviation;
            this.Name = Name;
        }

        public override string ToString()
        {
            return $"{_abbreviation} ({_id})";
        }
    }

    public class CourseHours : INotifyPropertyChanged
    {
        private int _id = 0;
        private int _courseId = 0;
        private int _lessonTypeId = 0;
        private int _hours = 0;

        //private string _lessonTypeAbbreviation = string.Empty;
        //private string _courseName = string.Empty;

        public int Id
        {
            get { return _id; }
            set { _id = value; OnPropertyChanged("Id"); }
        }
        public int CourseId
        {
            get { return _courseId; }
            set { _courseId = value; OnPropertyChanged("CourseId"); }
        }
        public int LessonTypeId
        {
            get { return _lessonTypeId; }
            set { _lessonTypeId = value; OnPropertyChanged("LessonTypeId"); }
        }
        public int Hours
        {
            get { return _hours; }
            set { _hours = value; OnPropertyChanged("Hours"); }
        }

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

        public CourseHours()
        {
        }
        public CourseHours(int Id, int CourseId, int LessonTypeId, int Hours)
        {
            this.Id = Id;
            this.CourseId = CourseId;
            this.LessonTypeId = LessonTypeId;
            this.Hours = Hours;
        }

        public override string ToString()
        {
            string lessonTypeAbbreviation = DBI.SelectReturnSingleValue("LessonType", "Abbreviation", _lessonTypeId);
            string courseName = DBI.SelectReturnSingleValue("Course", "Name", _courseId);

            return $"{_id} - {courseName} ({lessonTypeAbbreviation})";
        }
    }
}
