Neue Abwensenheitsmodi plus Upgrade Sitzplan
This commit is contained in:
@@ -107,6 +107,7 @@ public class SeatingPlanRepository(LiteDbContext db) : ISeatingPlanRepository
|
||||
plan.Name = plan.Name?.Trim() ?? "";
|
||||
plan.Room = plan.Room?.Trim() ?? "";
|
||||
plan.Assignments ??= [];
|
||||
plan.ColumnGapWidths ??= [];
|
||||
if (plan.Name.Length == 0)
|
||||
throw new ArgumentException("Der Name des Sitzplans darf nicht leer sein.");
|
||||
if (plan.Rows is < 1 or > 10 || plan.Columns is < 1 or > 10)
|
||||
@@ -114,6 +115,12 @@ public class SeatingPlanRepository(LiteDbContext db) : ISeatingPlanRepository
|
||||
if (db.Groups.FindById(plan.GroupId) is null)
|
||||
throw new InvalidOperationException("Die zugehörige Lerngruppe existiert nicht.");
|
||||
|
||||
plan.ColumnGapWidths = Enumerable.Range(0, Math.Max(0, plan.Columns - 1))
|
||||
.Select(i => i < plan.ColumnGapWidths.Count && double.IsFinite(plan.ColumnGapWidths[i])
|
||||
? Math.Clamp(plan.ColumnGapWidths[i], 0, 300)
|
||||
: 0)
|
||||
.ToList();
|
||||
|
||||
var duplicateName = db.SeatingPlans.Find(p => p.GroupId == plan.GroupId)
|
||||
.FirstOrDefault(p => p.Id != plan.Id
|
||||
&& string.Equals(p.Name, plan.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|
||||
Reference in New Issue
Block a user