Skip to content

Commit

Permalink
Merge pull request #96 from kzi-nastava/feat/CourseController-Update
Browse files Browse the repository at this point in the history
[Update] CourseController and Course Classes
  • Loading branch information
DusicaPesic authored Mar 31, 2024
2 parents 49e723a + d6a1c84 commit e8baee5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
12 changes: 12 additions & 0 deletions LangLang/Core/Controller/CourseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,17 @@ public Dictionary<int, Course> 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];
}
}
}
14 changes: 7 additions & 7 deletions LangLang/Core/Model/Course.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Course : ISerializable
private string _language;
private LanguageLevel _level;
private int _numberOfWeeks;
private List<WeekDays> _days;
private List<DayOfWeek> _days;
private bool _online;
private int _numberOfStudents;
private int _maxStudents;
Expand Down Expand Up @@ -53,7 +53,7 @@ public int NumberOfWeeks
get { return _numberOfWeeks; }
set { _numberOfWeeks = value; }
}
public List<WeekDays> Days
public List<DayOfWeek> Days
{
get { return _days; }
set { _days = value; }
Expand Down Expand Up @@ -85,7 +85,7 @@ public DateTime StartDateTime

// Constructors

public Course(int id, int tutorId, string language, LanguageLevel level, int numberOfWeeks, List<WeekDays> days,
public Course(int id, int tutorId, string language, LanguageLevel level, int numberOfWeeks, List<DayOfWeek> days,

Check warning on line 88 in LangLang/Core/Model/Course.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_language' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 88 in LangLang/Core/Model/Course.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_days' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
bool online, int maxStudents, DateTime startDateTime)
{
Id = id;
Expand All @@ -107,7 +107,7 @@ public Course()
public string ToString()

Check warning on line 107 in LangLang/Core/Model/Course.cs

View workflow job for this annotation

GitHub Actions / build

'Course.ToString()' hides inherited member 'object.ToString()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
{
StringBuilder sbDays = new StringBuilder();
foreach (WeekDays day in Days)
foreach (DayOfWeek day in Days)
{
sbDays.Append(day.ToString() + " ");
}
Expand All @@ -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() + " ");
}
Expand Down Expand Up @@ -159,10 +159,10 @@ public void FromCSV(string[] values)

// Converting from string to list of WeekDays
string[] days = values[4].Split(' ');
Days = new List<WeekDays>();
Days = new List<DayOfWeek>();
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]);
Expand Down
14 changes: 0 additions & 14 deletions LangLang/Core/Model/Enums/WeekDays.cs

This file was deleted.

0 comments on commit e8baee5

Please sign in to comment.