xxxproject/Demo/Data/Repository/SQLPresenceRepositoryLmpl.cs
Class_Student 6b9b5a424f init
2024-10-30 12:11:19 +03:00

46 lines
1.6 KiB
C#

using Demo.Data.Entity;
using Demo.Data.RemoteData.RemoteDataBase;
using Demo.Data.RemoteData.RemoteDataBase.DAO;
using System.Collections.Generic;
using System.Linq;
namespace Demo.Data.Repository
{
public class SQLPresenceRepositoryImpl : IPresenceRepository
{
private readonly RemoteDatabaseContex _remoteDatabaseContext;
public SQLPresenceRepositoryImpl(RemoteDatabaseContex remoteDatabaseContext)
{
_remoteDatabaseContext = remoteDatabaseContext;
}
public bool AddPresence(PresenceLocalEntity newPresence)
{
var presenceDao = new PresenceDao
{
UserGuid = newPresence.UserGuid,
IsAttedance = newPresence.IsAttedance, // Используем IsAttendance
Date = newPresence.Date,
LessonNumber = newPresence.LessonNumber
};
_remoteDatabaseContext.PresenceDaos.Add(presenceDao);
return _remoteDatabaseContext.SaveChanges() > 0; // Возвращаем true, если изменения сохранены
}
public List<PresenceLocalEntity> GetAllPresences()
{
return _remoteDatabaseContext.PresenceDaos
.Select(p => new PresenceLocalEntity
{
UserGuid = p.UserGuid,
IsAttedance = p.IsAttedance, // Обратите внимание на правильное название свойства
Date = p.Date,
LessonNumber = p.LessonNumber
})
.ToList();
}
}
}