using Zurnal.RemaDateBase.DateDao; internal interface IGroupRepository { List AllGroup { get; } public IEnumerable AllGroups() { return AllGroup.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id }); } public bool RemoveGroupById(int groupId) { var group = AllGroup.FirstOrDefault(g => g.Id == groupId); if (group != null) { AllGroup.Remove(group); return true; } return false; } public GroupDao FindGroupById(int groupId) { return AllGroup.FirstOrDefault(g => g.Id == groupId); } public bool UpdateGroupById(int groupId, GroupDao updatedGroup) { if (updatedGroup == null) throw new ArgumentNullException(nameof(updatedGroup)); var group = AllGroup.FirstOrDefault(g => g.Id == groupId); if (group != null) { group.GroupName = updatedGroup.GroupName; return true; } return false; } public void DeleteGroup(int id) { var group = AllGroup.FirstOrDefault(g => g.Id == id); if (group != null) { AllGroup.Remove(group); } } public IEnumerable GetAllGroups() { return AllGroup; } public void UpdateGroupName(int groupId, string name) { if (name == null) throw new ArgumentNullException(nameof(name)); var group = AllGroup.FirstOrDefault(g => g.Id == groupId); if (group != null) { group.GroupName = name; } } }