mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
started creating module ui, workign on assignments
This commit is contained in:
6
Management/Features/Modules/IModuleManager.cs
Normal file
6
Management/Features/Modules/IModuleManager.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
public interface IModuleManager
|
||||
{
|
||||
IEnumerable<CourseModule> Modules { get; }
|
||||
public void AddModule(CourseModule newModule);
|
||||
public void AddAssignment(int moduleIndex, LocalAssignment assignment);
|
||||
}
|
||||
22
Management/Features/Modules/ModuleManager.cs
Normal file
22
Management/Features/Modules/ModuleManager.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
public class ModuleManager : IModuleManager
|
||||
{
|
||||
public IEnumerable<CourseModule> Modules { get; internal set; } = new CourseModule[] { };
|
||||
|
||||
public void AddAssignment(int moduleIndex, LocalAssignment assignment)
|
||||
{
|
||||
var newAssignments = Modules.ElementAt(moduleIndex).Assignments.Append(assignment);
|
||||
var newModule = Modules.ElementAt(moduleIndex) with { Assignments = newAssignments };
|
||||
if (newModule == null)
|
||||
throw new Exception($"cannot get module at index {moduleIndex}");
|
||||
|
||||
Modules = Modules
|
||||
.Take(moduleIndex)
|
||||
.Append(newModule)
|
||||
.Concat(Modules.Skip(moduleIndex + 1));
|
||||
}
|
||||
|
||||
public void AddModule(CourseModule newModule)
|
||||
{
|
||||
Modules = Modules.Append(newModule);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user