Mitarbeit bewerten begonnen, Schülerdaten, Gruppen
This commit is contained in:
@@ -133,3 +133,49 @@ public class TimeEntryRepository(LiteDbContext db) : ITimeEntryRepository
|
||||
public void Save(TimeEntry e) => db.TimeEntries.Upsert(e);
|
||||
public void Delete(Guid id) => db.TimeEntries.Delete(id);
|
||||
}
|
||||
|
||||
public class ParticipationSessionRepository(LiteDbContext db) : IParticipationSessionRepository
|
||||
{
|
||||
public List<ParticipationSession> GetByGroup(Guid groupId) =>
|
||||
db.ParticipationSessions.Find(s => s.GroupId == groupId).OrderByDescending(s => s.Date).ToList();
|
||||
public ParticipationSession? GetById(Guid id) => db.ParticipationSessions.FindById(id);
|
||||
public void Save(ParticipationSession s) { s.UpdatedAt = DateTime.UtcNow; db.ParticipationSessions.Upsert(s); }
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
db.ParticipationSessions.Delete(id);
|
||||
foreach (var e in db.ParticipationEntries.Find(e => e.SessionId == id).ToList())
|
||||
db.ParticipationEntries.Delete(e.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class ParticipationRepository(LiteDbContext db) : IParticipationRepository
|
||||
{
|
||||
public List<ParticipationEntry> GetBySession(Guid sessionId) =>
|
||||
db.ParticipationEntries.Find(e => e.SessionId == sessionId).ToList();
|
||||
public List<ParticipationEntry> GetByStudent(Guid studentId) =>
|
||||
db.ParticipationEntries.Find(e => e.StudentId == studentId).ToList();
|
||||
public ParticipationEntry? GetBySessionAndStudent(Guid sessionId, Guid studentId) =>
|
||||
db.ParticipationEntries.FindOne(e => e.SessionId == sessionId && e.StudentId == studentId);
|
||||
public void Save(ParticipationEntry e) { e.UpdatedAt = DateTime.UtcNow; db.ParticipationEntries.Upsert(e); }
|
||||
public void SaveMany(List<ParticipationEntry> entries)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
foreach (var e in entries) e.UpdatedAt = now;
|
||||
db.ParticipationEntries.Upsert(entries);
|
||||
}
|
||||
public void DeleteBySession(Guid sessionId)
|
||||
{
|
||||
foreach (var e in db.ParticipationEntries.Find(e => e.SessionId == sessionId).ToList())
|
||||
db.ParticipationEntries.Delete(e.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class ParticipationAspectRepository(LiteDbContext db) : IParticipationAspectRepository
|
||||
{
|
||||
public List<ParticipationAspect> GetDefaults() =>
|
||||
db.ParticipationAspects.Find(a => a.GroupId == null && a.IsActive).OrderBy(a => a.SortOrder).ToList();
|
||||
public List<ParticipationAspect> GetByGroup(Guid groupId) =>
|
||||
db.ParticipationAspects.Find(a => a.GroupId == groupId && a.IsActive).OrderBy(a => a.SortOrder).ToList();
|
||||
public void Save(ParticipationAspect a) { a.UpdatedAt = DateTime.UtcNow; db.ParticipationAspects.Upsert(a); }
|
||||
public void Delete(Guid id) => db.ParticipationAspects.Delete(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user