using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Text;
using System.Threading.Tasks;

namespace Teachers.Models
{
    partial class Teacher
    {
        public string FIO => Name + " " + Patronymic + " " + Surname;
        public string CoursesHours
        {
            get
            {
                int hours = 0;
                foreach (var item in TeacherCourses)
                {
                    hours += (int)item.IdCourseNavigation.Duration;
                }
                return "Курсы в общем объеме " + hours + " часов:";
            }
        }

        public int CoursesHoursInt
        {
            get
            {
                int hours = 0;
                foreach (var item in TeacherCourses)
                {
                    hours += (int)item.IdCourseNavigation.Duration;
                }
                return hours;
            }
        }

        public string Exp
        {
            get
            {
                string wordForYears = "", wordForMonths = "";
                int years = (int)(Experience / 12);
                char c = years.ToString().ToCharArray()[years.ToString().Length - 1];
                if (years >= 11 && years <= 19) wordForYears = " лет ";
                else if (c == '1') wordForYears = " год ";
                else if (c == '2' || c == '3' || c == '4') wordForYears = " года ";
                else if (c == '0' || (c >= '5' && c <= '9')) wordForYears = " лет ";

                int months = (int)(Experience - years * 12);
                if (months == 0 || (months <= 11 && months >= 5)) wordForMonths = " месяцев ";
                else if (months == 1) wordForMonths = " месяц ";
                else if (months >= 2 && months <= 4) wordForMonths = " месяца ";

                return years + wordForYears + months + wordForMonths;
            }
        }
    }
}
