using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Posechaemost.Data.LocalData; using Posechaemost.Data.LocalData.Entity; using Posechaemost.Domain.Models; namespace Posechaemost.Data.Repository { public class PresenceRepositoryImpl: IPresenceRepository { public PresenceRepositoryImpl() { GetAllPresences = LocalStaticData.presences; } public List GetAllPresences { get; set; } public void AddPresence(PresenceLocalEntity presence) { PresenceLocalEntity? presenceLocal = GetAllPresences.FirstOrDefault(); // GroupLocalEntity? group = new GroupLocalEntity(); presenceLocal.ClassNumber = presence.ClassNumber; presence.UserGuid = presence.UserGuid; presenceLocal.Date = presence.Date; presenceLocal.IsAttendence = presence.IsAttendence; } public List GetPresenceByGroup(int groupId) { return GetAllPresences; } public List GetPresenceByGroupAndDate(int groupId, DateOnly date) { return GetAllPresences; } public bool UncheckAttendence(PresenceLocalEntity presence) { var presToUpdate = GetAllPresences .Where(x => x.IsAttendence == presence.IsAttendence && x.UserGuid == presence.UserGuid && x.Date == presence.Date && x.ClassNumber == presence.ClassNumber).ToList(); foreach (var pres in presToUpdate) { presence.IsAttendence = false; } return true; } } }