using Zurnal.RemaDateBase.DateDao; public class PresenceRepository : IPresenceRepository { private List presences = new List(); public void AddPresence(PresnceDao presence) { presences.Add(new PresnceDao { UserGuid = presence.UserGuid, IsAttendensy = presence.IsAttendensy, LessonNumber = presence.LessonNumber, Date = presence.Date, userDao = new UserDao { FIO = presence.userDao.FIO, UserGuid = presence.userDao.UserGuid, GroupID = presence.userDao.GroupID, Group = new GroupDao { Id = presence.userDao.Group.Id, GroupName = presence.userDao.Group.GroupName } } }); } public PresnceDao GetPresenceById(int id) { var presence = presences.FirstOrDefault(p => p.LessonNumber == id); return presence != null ? new PresnceDao { UserGuid = presence.UserGuid, IsAttendensy = presence.IsAttendensy, LessonNumber = presence.LessonNumber, Date = presence.Date, userDao = new UserDao { FIO = presence.userDao.FIO, GroupID = presence.userDao.GroupID, Group = presence.userDao.Group } } : null; } public IEnumerable GetAllPresences() { return presences.Select(p => new PresnceDao { UserGuid = p.UserGuid, IsAttendensy = p.IsAttendensy, LessonNumber = p.LessonNumber, Date = p.Date, userDao = new UserDao { FIO = p.userDao.FIO, GroupID = p.userDao.GroupID, Group = p.userDao.Group } }).ToList(); } public void UpdatePresence(PresnceDao presence) { var existingPresence = presences.FirstOrDefault(p => p.LessonNumber == presence.LessonNumber); if (existingPresence != null) { existingPresence.IsAttendensy = presence.IsAttendensy; existingPresence.Date = presence.Date; existingPresence.userDao.FIO = presence.userDao.FIO; existingPresence.userDao.GroupID = presence.userDao.GroupID; existingPresence.userDao.Group.GroupName = presence.userDao.Group.GroupName; } } public void DeletePresence(int id) { var presence = presences.FirstOrDefault(p => p.LessonNumber == id); if (presence != null) { presences.Remove(presence); } } }