diff --git a/LangLang/Core/Controller/CourseController.cs b/LangLang/Core/Controller/CourseController.cs index 00142a5f..fb0fe5f1 100644 --- a/LangLang/Core/Controller/CourseController.cs +++ b/LangLang/Core/Controller/CourseController.cs @@ -97,5 +97,17 @@ public Dictionary GetCoursesByTutor(int tutorId) return coursesByTutor; } + // Method returns DateTime of the beginning of the last class of the course + public DateTime GetCourseEnd(Course course) + { + DateTime end = course.StartDateTime.AddDays(7 * course.NumberOfWeeks); + DayOfWeek endDay = course.Days[course.Days.Count - 1]; + return end.AddDays((int)endDay - (int)end.DayOfWeek); + } + + public Course GetById(int courseId) + { + return _courses.GetAllCourses()[courseId]; + } } } \ No newline at end of file diff --git a/LangLang/Core/Model/Course.cs b/LangLang/Core/Model/Course.cs index 4f836691..e41feeb0 100644 --- a/LangLang/Core/Model/Course.cs +++ b/LangLang/Core/Model/Course.cs @@ -16,7 +16,7 @@ public class Course : ISerializable private string _language; private LanguageLevel _level; private int _numberOfWeeks; - private List _days; + private List _days; private bool _online; private int _numberOfStudents; private int _maxStudents; @@ -53,7 +53,7 @@ public int NumberOfWeeks get { return _numberOfWeeks; } set { _numberOfWeeks = value; } } - public List Days + public List Days { get { return _days; } set { _days = value; } @@ -85,7 +85,7 @@ public DateTime StartDateTime // Constructors - public Course(int id, int tutorId, string language, LanguageLevel level, int numberOfWeeks, List days, + public Course(int id, int tutorId, string language, LanguageLevel level, int numberOfWeeks, List days, bool online, int maxStudents, DateTime startDateTime) { Id = id; @@ -107,7 +107,7 @@ public Course() public string ToString() { StringBuilder sbDays = new StringBuilder(); - foreach (WeekDays day in Days) + foreach (DayOfWeek day in Days) { sbDays.Append(day.ToString() + " "); } @@ -124,7 +124,7 @@ public string ToString() public string[] ToCSV() { StringBuilder sbDays = new StringBuilder(); - foreach (WeekDays day in Days) + foreach (DayOfWeek day in Days) { sbDays.Append(day.ToString() + " "); } @@ -159,10 +159,10 @@ public void FromCSV(string[] values) // Converting from string to list of WeekDays string[] days = values[4].Split(' '); - Days = new List(); + Days = new List(); foreach (string day in days) { - Days.Add((WeekDays)Enum.Parse(typeof(WeekDays), day)); + Days.Add((DayOfWeek)Enum.Parse(typeof(DayOfWeek), day)); } Online = bool.Parse(values[5]); diff --git a/LangLang/Core/Model/Enums/WeekDays.cs b/LangLang/Core/Model/Enums/WeekDays.cs deleted file mode 100644 index a5f57f1c..00000000 --- a/LangLang/Core/Model/Enums/WeekDays.cs +++ /dev/null @@ -1,14 +0,0 @@ - -namespace LangLang.Core.Model -{ - public enum WeekDays - { - Monday, - Tuesday, - Wednesday, - Thursday, - Friday, - Saturday, - Sunday - } -}