@page "/" @using CanvasModel.EnrollmentTerms @using Management.Web.Shared.Semester @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage @inject ICanvasService canvasService @inject IConfigurationManagement configurationManagement @inject ProtectedSessionStorage ProtectedSessionStore @code { private IEnumerable? terms { get; set; } = null; private ulong? selectedTermId { get; set; } private EnrollmentTermModel? selectedTerm { get => terms?.FirstOrDefault(t => t.Id == selectedTermId); } private List days { get; set; } = new(); private bool saved { get; set; } = false; protected override async Task OnInitializedAsync() { terms = await canvasService.GetCurrentTermsFor(); readTermFromConfig(); readDaysFromConfig(); } private void readTermFromConfig() { if (terms == null || configurationManagement.Configuration == null) return; foreach (var term in terms) { var termInConfiguration = configurationManagement.Configuration.StartDate == term.StartAt; if (termInConfiguration) { selectedTermId = term.Id; } } } private void readDaysFromConfig() { if (terms == null || configurationManagement.Configuration == null) return; days = configurationManagement.Configuration.Days.ToList(); } public async void HandleSave() { saved = true; configurationManagement.SetConfiguration(selectedTerm, days.ToArray()); await ProtectedSessionStore.SetAsync("configuration", configurationManagement.Configuration); } } Index @if (terms != null) {
Select Term:
} @if (selectedTerm is not null) {
Select Days Of Week
@foreach (DayOfWeek day in (DayOfWeek[])Enum.GetValues(typeof(DayOfWeek))) {
}
} @if (configurationManagement.Configuration is not null) {
Config complete
}