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 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(); } } } }