using System.Diagnostics; using Zurnal.RemaDateBase.DateDao; using System.Text.RegularExpressions; namespace Zurnal.Data.Repository { [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public class GroupRepositoryImpl : IGroupRepository { public List AllGroup => GroupDao.Name.ToList(); public IEnumerable GetAllGroups() { return GroupDao.Name; } public void AddGroup(GroupDao group) { if (group == null) { throw new ArgumentNullException(nameof(group)); } GroupDao.Name.Add(group); } public void UpdateGroupName(int groupId, string name) { var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId); if (group != null) { group.GroupName = name; } } public bool UpdateGroupById(int groupId, GroupDao updatedGroup) { var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId); if (group != null) { group.GroupName = updatedGroup.GroupName; return true; } return false; } private static string GetDebuggerDisplay() { return $"GroupRepository with {GroupDao.Name.Count} groups"; } public bool RemoveGroupById(int groupId) { var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId); if (group != null) { GroupDao.Name.Remove(group); return true; } return false; } public IEnumerable AllGroups() { return GroupDao.Name.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id }); } public void DeleteGroup(int id) { var group = GroupDao.Name.FirstOrDefault(g => g.Id == id); if (group != null) { GroupDao.Name.Remove(group); } } public void UpdateGroup(GroupDao group) { throw new NotImplementedException(); } } }