From 986a196a416ff73b3f8742926a65ff7467357c41 Mon Sep 17 00:00:00 2001 From: Darinka Loncar <149894872+darinkaloncar@users.noreply.github.com> Date: Sun, 31 Mar 2024 05:36:57 -0700 Subject: [PATCH 1/3] [Update] name of parameter in method IsCourseValid --- LangLang/Core/Controller/CourseController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LangLang/Core/Controller/CourseController.cs b/LangLang/Core/Controller/CourseController.cs index 204e750a..6644fc95 100644 --- a/LangLang/Core/Controller/CourseController.cs +++ b/LangLang/Core/Controller/CourseController.cs @@ -38,7 +38,7 @@ public void Subscribe(IObserver observer) // Method checks if the course is valid for updating or canceling public bool IsCourseValid(int courseId) { - Course course = GetAllCourses()[id]; + Course course = GetAllCourses()[courseId]; TimeSpan difference = course.StartDate - DateTime.Now; return difference.TotalDays < 7; } From 9dfcbeb4272a34e5db80403fe1ca7a91cf016911 Mon Sep 17 00:00:00 2001 From: Darinka Loncar <149894872+darinkaloncar@users.noreply.github.com> Date: Sun, 31 Mar 2024 05:51:48 -0700 Subject: [PATCH 2/3] [Update] attribute name in Course class --- LangLang/Core/Model/Course.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/LangLang/Core/Model/Course.cs b/LangLang/Core/Model/Course.cs index b408b105..4f836691 100644 --- a/LangLang/Core/Model/Course.cs +++ b/LangLang/Core/Model/Course.cs @@ -20,7 +20,7 @@ public class Course : ISerializable private bool _online; private int _numberOfStudents; private int _maxStudents; - private DateTime _startDate; + private DateTime _startDateTime; // Properties @@ -77,16 +77,16 @@ public int MaxStudents set { _maxStudents = value; } } - public DateTime StartDate + public DateTime StartDateTime { - get { return _startDate; } - set { _startDate = value; } + get { return _startDateTime; } + set { _startDateTime = value; } } // Constructors public Course(int id, int tutorId, string language, LanguageLevel level, int numberOfWeeks, List days, - bool online, int maxStudents, DateTime startDate) + bool online, int maxStudents, DateTime startDateTime) { Id = id; TutorId = tutorId; @@ -97,7 +97,7 @@ public Course(int id, int tutorId, string language, LanguageLevel level, int num Online = online; NumberOfStudents = 0; MaxStudents = maxStudents; - StartDate = startDate; + StartDateTime = startDateTime; } public Course() @@ -118,7 +118,7 @@ public string ToString() sbDays.Remove(sbDays.Length - 1, 1); } - return $"ID: {Id,5} | Language: {Language,20} | Level: {Level,5} | NumberOfWeeks: {NumberOfWeeks,5} | Days: {sbDays, 10} | Online: {Online,5} | NumberOfStudents : {NumberOfStudents,5} | MaxStudents : {MaxStudents,5} | CreationDate : {StartDate,10} |"; + return $"ID: {Id,5} | Language: {Language,20} | Level: {Level,5} | NumberOfWeeks: {NumberOfWeeks,5} | Days: {sbDays, 10} | Online: {Online,5} | NumberOfStudents : {NumberOfStudents,5} | MaxStudents : {MaxStudents,5} | StartDateTime : {StartDateTime,10} |"; } public string[] ToCSV() @@ -145,7 +145,7 @@ public string[] ToCSV() Online.ToString(), NumberOfStudents.ToString(), MaxStudents.ToString(), - StartDate.ToString() + StartDateTime.ToString() }; return csvValues; } @@ -168,7 +168,7 @@ public void FromCSV(string[] values) Online = bool.Parse(values[5]); NumberOfStudents = int.Parse(values[6]); MaxStudents = int.Parse(values[7]); - StartDate = DateTime.Parse(values[8]); + StartDateTime = DateTime.Parse(values[8]); } } } From dc851cce8eee73022d91ee10c57541cfb869742e Mon Sep 17 00:00:00 2001 From: Darinka Loncar <149894872+darinkaloncar@users.noreply.github.com> Date: Sun, 31 Mar 2024 06:23:45 -0700 Subject: [PATCH 3/3] [Add] function GetCoursesByTutor to CourseController Class --- LangLang/Core/Controller/CourseController.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/LangLang/Core/Controller/CourseController.cs b/LangLang/Core/Controller/CourseController.cs index 6644fc95..00142a5f 100644 --- a/LangLang/Core/Controller/CourseController.cs +++ b/LangLang/Core/Controller/CourseController.cs @@ -35,11 +35,12 @@ public void Subscribe(IObserver observer) _courses.Subscribe(observer); } + // Method checks if the course is valid for updating or canceling public bool IsCourseValid(int courseId) { Course course = GetAllCourses()[courseId]; - TimeSpan difference = course.StartDate - DateTime.Now; + TimeSpan difference = course.StartDateTime - DateTime.Now; return difference.TotalDays < 7; } @@ -47,7 +48,7 @@ public bool IsCourseValid(int courseId) public bool IsCourseAvailable(int courseId) { Course course = GetAllCourses()[courseId]; - TimeSpan difference = course.StartDate - DateTime.Now; + TimeSpan difference = course.StartDateTime - DateTime.Now; if (difference.TotalDays < 7) { if (course.Online) @@ -81,5 +82,20 @@ public Dictionary GetCoursesByTutor(Tutor tutor) return coursesByTutor; } + public Dictionary GetCoursesByTutor(int tutorId) + { + Dictionary coursesByTutor = new Dictionary(); + + foreach (Course course in GetAllCourses().Values) + { + if (course.TutorId == tutorId) + { + coursesByTutor[course.Id] = course; + } + } + + return coursesByTutor; + } + } } \ No newline at end of file