PartialTeacher.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reactive;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Teachers.Models
  8. {
  9. partial class Teacher
  10. {
  11. public string FIO => Name + " " + Patronymic + " " + Surname;
  12. public string CoursesHours
  13. {
  14. get
  15. {
  16. int hours = 0;
  17. foreach (var item in TeacherCourses)
  18. {
  19. hours += (int)item.IdCourseNavigation.Duration;
  20. }
  21. return "Курсы в общем объеме " + hours + " часов:";
  22. }
  23. }
  24. public string Exp
  25. {
  26. get
  27. {
  28. string wordForYears = "", wordForMonths = "";
  29. int years = (int)(Experience / 12);
  30. char c = years.ToString().ToCharArray()[years.ToString().Length - 1];
  31. if (years >= 11 && years <= 19) wordForYears = " лет ";
  32. else if (c == '1') wordForYears = " год ";
  33. else if (c == '2' || c == '3' || c == '4') wordForYears = " года ";
  34. else if (c == '0' || (c >= '5' && c <= '9')) wordForYears = " лет ";
  35. int months = (int)(Experience - years * 12);
  36. if (months == 0 || (months <= 11 && months >= 5)) wordForMonths = " месяцев ";
  37. else if (months == 1) wordForMonths = " месяц ";
  38. else if (months >= 2 && months <= 4) wordForMonths = " месяца ";
  39. return years + wordForYears + months + wordForMonths;
  40. }
  41. }
  42. }
  43. }