Raspisanie/Zurnal/Date/Repository/PresenceRepositoryIml.cs

51 lines
1.3 KiB
C#
Raw Permalink Normal View History

2024-11-08 06:59:01 +00:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Zurnal.RemaDateBase.DateDao;
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
public class PresenceRepositoryIml : IPresenceRepository
{
private readonly List<PresnceDao> _presences = new List<PresnceDao>();
public void AddPresence(PresnceDao presence)
{
_presences.Add(presence);
}
public PresnceDao GetPresenceById(int id)
{
return _presences.Find(p => p.LessonNumber == id);
}
public IEnumerable<PresnceDao> GetAllPresences()
{
return _presences;
}
public void UpdatePresence(PresnceDao presence)
{
var existingPresence = GetPresenceById(presence.LessonNumber);
if (existingPresence != null)
{
existingPresence.UserGuid = presence.UserGuid;
existingPresence.IsAttendensy = presence.IsAttendensy;
existingPresence.Date = presence.Date;
existingPresence.userDao = presence.userDao;
}
}
public void DeletePresence(int id)
{
var presence = GetPresenceById(id);
if (presence != null)
{
_presences.Remove(presence);
}
}
private string GetDebuggerDisplay()
{
return ToString();
}
}