// C:\Users\adm\Source\Repos\presence1\Demo\Data\Repository\GroupRepositoryImpl.cs using System.Collections.Generic; using System.Linq; using Demo.Data.Exceptions; using Demo.Data.LocalData; using Demo.Data.LocalData.Entity; using Demo.Data.RemoteData.RemoteDataBase; namespace Demo.Data.Repository { public class GroupRepositoryImpl : IGroupRepository { private RemoteDatabaseContext context; public GroupRepositoryImpl(RemoteDatabaseContext context) { this.context = context; } public void AddGroup(Group group) { if (LocalStaticData.Groups.Any(g => g.Id == group.Id)) throw new RepositoryException("Group with the same ID already exists."); LocalStaticData.Groups.Add(group); } public void DeleteGroup(int id) { var group = GetGroupById(id); LocalStaticData.Groups.Remove(group); } public IEnumerable GetAllGroups() { return LocalStaticData.Groups; } public Group GetGroupById(int id) { var group = LocalStaticData.Groups.FirstOrDefault(g => g.Id == id); if (group == null) throw new GroupNotFoundException(id); return group; } public void UpdateGroup(Group group) { var existingGroup = GetGroupById(group.Id); existingGroup.Name = group.Name; } } }