-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement better GetSchedules endpoint, including course dates
- Loading branch information
Showing
8 changed files
with
110 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Gordon360.Models.CCT; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Gordon360.Models.ViewModels; | ||
|
||
public record ScheduleCourseViewModel | ||
{ | ||
public string Code { get; set; } | ||
public string Title { get; set; } | ||
public string Role { get; set; } | ||
public string? Location { get; set; } | ||
public List<char> MeetingDays { get; set; } | ||
public TimeOnly? BeginTime { get; set; } | ||
public TimeOnly? EndTime { get; set; } | ||
public DateOnly? BeginDate { get; set; } | ||
public DateOnly? EndDate { get; set; } | ||
public string YearTermCode { get; set; } | ||
|
||
|
||
public static implicit operator ScheduleCourseViewModel(UserCourses course) | ||
{ | ||
List<char> meetingDays = new(); | ||
if (course.MONDAY_CDE == "M") | ||
{ | ||
meetingDays.Add('M'); | ||
} | ||
if (course.TUESDAY_CDE == "T") | ||
{ | ||
meetingDays.Add('T'); | ||
} | ||
if (course.WEDNESDAY_CDE == "W") | ||
{ | ||
meetingDays.Add('W'); | ||
} | ||
if (course.THURSDAY_CDE == "R") | ||
{ | ||
meetingDays.Add('R'); | ||
} | ||
if (course.FRIDAY_CDE == "F") | ||
{ | ||
meetingDays.Add('F'); | ||
} | ||
if (course.SATURDAY_CDE == "S") | ||
{ | ||
meetingDays.Add('S'); | ||
} | ||
if (course.MONDAY_CDE == "U") | ||
{ | ||
meetingDays.Add('U'); | ||
} | ||
|
||
return new ScheduleCourseViewModel() | ||
{ | ||
Code = course.CRS_CDE.Trim(), | ||
Title = course.CRS_TITLE.Trim(), | ||
Role = course.Role, | ||
Location = (course.BLDG_CDE, course.ROOM_CDE) switch | ||
{ | ||
(string building_code, string room_code) => $"{building_code} {room_code}", | ||
(string building_code, null) => building_code, | ||
_ => null | ||
}, | ||
MeetingDays = meetingDays, | ||
BeginTime = course.BEGIN_TIME is TimeSpan BeginTime ? TimeOnly.FromTimeSpan(BeginTime) : null, | ||
EndTime = course.END_TIME is TimeSpan EndTime ? TimeOnly.FromTimeSpan(EndTime) : null, | ||
BeginDate = course.BEGIN_DATE is DateTime BeginDate ? DateOnly.FromDateTime(BeginDate) : null, | ||
EndDate = course.END_DATE is DateTime EndDate ? DateOnly.FromDateTime(EndDate) : null, | ||
YearTermCode = course.YR_CDE + course.TRM_CDE, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,6 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Gordon360.Models.ViewModels | ||
{ | ||
public class ScheduleViewModel | ||
{ | ||
public int ID_NUM { get; set; } | ||
public string CRS_CDE { get; set; } | ||
public string CRS_TITLE { get; set; } | ||
namespace Gordon360.Models.ViewModels; | ||
|
||
public string BLDG_CDE { get; set; } | ||
|
||
public string ROOM_CDE { get; set; } | ||
|
||
public string MONDAY_CDE { get; set; } | ||
public string TUESDAY_CDE { get; set; } | ||
public string WEDNESDAY_CDE { get; set; } | ||
public string THURSDAY_CDE { get; set; } | ||
public string FRIDAY_CDE { get; set; } | ||
|
||
public TimeSpan? BEGIN_TIME { get; set; } | ||
|
||
public TimeSpan? END_TIME { get; set; } | ||
|
||
|
||
} | ||
|
||
|
||
} | ||
public record ScheduleViewModel(SessionViewModel Session, IEnumerable<ScheduleCourseViewModel> Courses); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.