presence/Demo/Data/Repository/PresenceRepositoryImpl.cs

54 lines
1.6 KiB
C#
Raw Permalink Normal View History

2024-10-23 09:44:48 +00:00
using Demo.Data.LocalData;
2024-10-25 08:47:11 +00:00
using Demo.Data.RemoteData.RemoteDataBase;
using Demo.Data.RemoteData.RemoteDataBase.DAO;
2024-10-23 09:44:48 +00:00
using Demo.domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Demo.Data.Repository
{
2024-10-28 12:03:51 +00:00
public class PresenceRepositoryImpl
2024-10-23 09:44:48 +00:00
{
private List<PresenceLocalEntity> _presences;
public PresenceRepositoryImpl()
{
2024-10-24 08:39:55 +00:00
_presences = new List<PresenceLocalEntity>(); // Ваши реальные данные
2024-10-23 09:44:48 +00:00
}
public void SavePresence(List<PresenceLocalEntity> presences)
{
foreach (var presence in presences)
{
var existingPresence = _presences.FirstOrDefault(p =>
p.Date == presence.Date &&
p.UserId == presence.UserId &&
p.LessonNumber == presence.LessonNumber);
if (existingPresence == null)
{
_presences.Add(presence);
}
else
{
existingPresence.IsAttedance = presence.IsAttedance;
}
}
}
2024-10-24 08:39:55 +00:00
public List<PresenceLocalEntity> GetPresenceByDateAndGroup(DateTime date, int groupId)
{
return _presences.Where(p => p.Date.Date == date.Date &&
LocalStaticData.users.Any(u => u.GroupID == groupId && u.ID == p.UserId)).ToList();
}
2024-10-25 08:47:11 +00:00
public List<PresenceLocalEntity> GetPresenceByGroup(int groupId)
2024-10-23 09:44:48 +00:00
{
2024-10-25 08:47:11 +00:00
return _presences.Where(p => p.GroupId == groupId).ToList();
2024-10-23 09:44:48 +00:00
}
2024-11-01 09:42:31 +00:00
2024-10-23 09:44:48 +00:00
}
}