using Demo.Data.Entity; using Demo.Data.LocalData; using Demo.domain.Models; using System.Collections.Generic; using System.Linq; namespace Demo.Data.Repository { public class GroupRepositoryImpl : IGroupRepository { public List GetAllGroups { get; private set; } public GroupRepositoryImpl() { GetAllGroups = LocalStaticData.groups; } public List GetAllGroup() { return GetAllGroups; } public GroupLocalEntity GetGroupById(int groupID) { return GetAllGroups.FirstOrDefault(g => g.Id == groupID); } public bool RemoveGroupById(int groupID) { var group = GetAllGroups.FirstOrDefault(g => g.Id == groupID); if (group != null) { GetAllGroups.Remove(group); return true; } return false; } public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup) { var existingGroup = GetAllGroups.FirstOrDefault(g => g.Id == groupID); if (existingGroup != null) { existingGroup.Name = updatedGroup.Name; return true; } return false; } public bool AddGroup(GroupLocalEntity newGroup) { if (GetAllGroups.Any(g => g.Id == newGroup.Id)) { return false; } GetAllGroups.Add(newGroup); return true; } } }