mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
better class day highlighting
This commit is contained in:
@@ -2,23 +2,26 @@ using CanvasModel.EnrollmentTerms;
|
||||
|
||||
public class SemesterPlanner
|
||||
{
|
||||
public DateTime FirstDay { get; }
|
||||
public DateTime LastDay { get; }
|
||||
|
||||
public IEnumerable<CalendarMonth> Months { get; }
|
||||
public IEnumerable<DayOfWeek> Days { get; }
|
||||
public SemesterPlanner(SemesterConfiguration configuration)
|
||||
{
|
||||
var start = configuration.StartDate;
|
||||
var end = configuration.EndDate;
|
||||
FirstDay = configuration.StartDate;
|
||||
LastDay = configuration.EndDate;
|
||||
|
||||
var monthsInTerm =
|
||||
1 + ((end.Year - start.Year) * 12)
|
||||
+ end.Month - start.Month;
|
||||
1 + ((LastDay.Year - FirstDay.Year) * 12)
|
||||
+ LastDay.Month - FirstDay.Month;
|
||||
|
||||
Months = Enumerable
|
||||
.Range(0, monthsInTerm)
|
||||
.Select(monthDiff =>
|
||||
{
|
||||
var month = ((start.Month + monthDiff - 1) % 12) + 1;
|
||||
var year = start.Year + ((start.Month + monthDiff - 1) / 12);
|
||||
var month = ((FirstDay.Month + monthDiff - 1) % 12) + 1;
|
||||
var year = FirstDay.Year + ((FirstDay.Month + monthDiff - 1) / 12);
|
||||
return new CalendarMonth(year, month);
|
||||
});
|
||||
Days = configuration.Days;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using CanvasModel.EnrollmentTerms;
|
||||
|
||||
public class ConfigurationManagement
|
||||
public class ConfigurationManagement : IConfigurationManagement
|
||||
{
|
||||
public static SemesterConfiguration CreateFromTerm(
|
||||
public void SetConfiguration(
|
||||
EnrollmentTermModel canvasTerm,
|
||||
DayOfWeek[] daysOfWeek
|
||||
)
|
||||
@@ -10,10 +10,15 @@ public class ConfigurationManagement
|
||||
var start = canvasTerm.StartAt ?? throw new Exception($"Canvas Term must have a start date. Term: {canvasTerm.Name}");
|
||||
var end = canvasTerm.EndAt ?? throw new Exception($"Canvas Term must have a end date. Term: {canvasTerm.Name}");
|
||||
|
||||
return new SemesterConfiguration(
|
||||
Configuration = new SemesterConfiguration(
|
||||
StartDate: start,
|
||||
EndDate: end,
|
||||
Days: daysOfWeek
|
||||
);
|
||||
}
|
||||
|
||||
public SemesterConfiguration? Configuration { get; private set; } = null;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using CanvasModel.EnrollmentTerms;
|
||||
|
||||
public interface IConfigurationManagement
|
||||
{
|
||||
SemesterConfiguration? Configuration { get; }
|
||||
|
||||
void SetConfiguration(EnrollmentTermModel canvasTerm, DayOfWeek[] daysOfWeek);
|
||||
}
|
||||
Reference in New Issue
Block a user