slarny4/Demo1/Data/Repository/PresenceRepositoryImpl.cs

70 lines
2.2 KiB
C#
Raw Permalink Normal View History

2024-10-28 12:42:04 +00:00
// C:\Users\adm\Source\Repos\presence1\Demo\Data\Repository\PresenceRepositoryImpl.cs
using System;
2024-10-24 08:50:32 +00:00
using System.Collections.Generic;
using System.Linq;
2024-10-28 12:42:04 +00:00
using AttendanceApp.Domain.Models;
using Demo.Data.LocalData;
using Demo.Data.LocalData.Entity;
using Demo.Data.RemoteData.RemoteDataBase;
2024-10-24 08:50:32 +00:00
2024-10-28 12:42:04 +00:00
namespace Demo.Data.Repository
2024-10-24 08:50:32 +00:00
{
public class PresenceRepositoryImpl : IPresenceRepository
{
2024-10-28 12:42:04 +00:00
private RemoteDatabaseContext context;
2024-10-24 08:50:32 +00:00
2024-10-28 12:42:04 +00:00
public PresenceRepositoryImpl(RemoteDatabaseContext context)
2024-10-24 08:50:32 +00:00
{
2024-10-28 12:42:04 +00:00
this.context = context;
2024-10-24 08:50:32 +00:00
}
2024-10-28 12:42:04 +00:00
public void AddPresence(LocalPresence presence)
2024-10-24 08:50:32 +00:00
{
2024-10-28 12:42:04 +00:00
LocalStaticData.Presences.Add(presence);
}
2024-10-24 08:50:32 +00:00
2024-10-28 12:42:04 +00:00
public IEnumerable<LocalPresence> GetAllPresences()
{
return LocalStaticData.Presences;
2024-10-24 08:50:32 +00:00
}
2024-10-28 12:42:04 +00:00
public IEnumerable<object> GetPresenceByGroup(int groupId)
2024-10-24 08:50:32 +00:00
{
2024-10-28 12:42:04 +00:00
throw new NotImplementedException();
2024-10-24 08:50:32 +00:00
}
2024-10-28 12:42:04 +00:00
public IEnumerable<object> GetPresenceByGroupAndDate(int groupId, DateTime date)
2024-10-24 08:50:32 +00:00
{
2024-10-28 12:42:04 +00:00
throw new NotImplementedException();
}
public IEnumerable<LocalPresence> GetPresencesByGroupAndDate(int groupId, DateTime date)
{
var usersInGroup = LocalStaticData.Users.Where(u => u.GroupID == groupId).Select(u => u.Id).ToList();
return LocalStaticData.Presences.Where(p => usersInGroup.Contains(p.UserId) && p.ClassDate.Date == date.Date);
}
public void UpdatePresence(LocalPresence presence)
{
var existingPresence = LocalStaticData.Presences.FirstOrDefault(p =>
2024-10-24 08:50:32 +00:00
p.UserId == presence.UserId &&
p.ClassDate.Date == presence.ClassDate.Date &&
2024-10-28 12:42:04 +00:00
p.LessonNumber == presence.LessonNumber);
2024-10-24 08:50:32 +00:00
2024-10-28 12:42:04 +00:00
if (existingPresence != null)
{
existingPresence.WasPresent = presence.WasPresent;
}
}
2024-10-24 08:50:32 +00:00
2024-10-28 12:42:04 +00:00
public void UpdatePresence(Presence presence)
{
throw new NotImplementedException();
}
IEnumerable<LocalPresence> IPresenceRepository.GetPresenceByGroup(int groupId)
{
throw new NotImplementedException();
2024-10-24 08:50:32 +00:00
}
}
}