49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using Zurnal.Date.LocalDate;
|
|
using Zurnal.domain.Models;
|
|
using Zurnal.RemaDateBase.DateDao;
|
|
|
|
namespace Zurnal.Date.Repository.SQLRepos
|
|
{
|
|
public class SQLPresenceRepositoryImpl : IPresenceRepository
|
|
{
|
|
private readonly RemoteDateBaseContext _remoteDataBaseContext;
|
|
|
|
public SQLPresenceRepositoryImpl(RemoteDateBaseContext remoteDataBaseContext) {
|
|
_remoteDataBaseContext = remoteDataBaseContext;
|
|
}
|
|
|
|
public void AddPresence(PresnceDao presence)
|
|
{
|
|
var result = _remoteDataBaseContext.Presence.Add(presence);
|
|
if (result != null) {
|
|
_remoteDataBaseContext.SaveChanges();
|
|
}
|
|
}
|
|
|
|
public PresnceDao GetPresenceById(int id)
|
|
{
|
|
return _remoteDataBaseContext.Presence.Find(id);
|
|
}
|
|
|
|
public IEnumerable<PresnceDao> GetAllPresences()
|
|
{
|
|
return _remoteDataBaseContext.Presence.ToList();
|
|
}
|
|
|
|
public void UpdatePresence(PresnceDao presence)
|
|
{
|
|
_remoteDataBaseContext.Presence.Update(presence);
|
|
_remoteDataBaseContext.SaveChanges();
|
|
}
|
|
|
|
public void DeletePresence(int id)
|
|
{
|
|
var presence = GetPresenceById(id);
|
|
if (presence != null)
|
|
{
|
|
_remoteDataBaseContext.Presence.Remove(presence);
|
|
_remoteDataBaseContext.SaveChanges();
|
|
}
|
|
}
|
|
}
|
|
} |