using Demo.Domain.Models; using Demo.Data.LocalData; namespace Demo.Data.Repository { public class GroupRepositoryImpl : IGroupRepository { public GroupRepositoryImpl() { GetAllGroups = LocalStaticData.groups; } public List GetAllGroups { get; set; } public List GetAllGroup() { return GetAllGroups; } public GroupLocalEntity? CreateGroup(GroupLocalEntity groupCreateLocalEntity) { if (GetAllGroups.Any(x => x.ID == groupCreateLocalEntity.ID)) return null; GetAllGroups.Add(groupCreateLocalEntity); return groupCreateLocalEntity; } public GroupLocalEntity? UpdateGroup(GroupLocalEntity updatedGroup) { int index = GetAllGroups.FindIndex(x => x.ID == updatedGroup.ID); if (index == -1) return null; GetAllGroups[index].Name = updatedGroup.Name; Console.WriteLine($"Обновленный Name: {GetAllGroups[index].Name}"); return GetAllGroups[index]; } public bool RemoveGroupByID(int groupId) { GroupLocalEntity? groupLocal = GetAllGroups .Where(x => x.ID == groupId).FirstOrDefault(); if (groupLocal == null) return false; return GetAllGroups.Remove(groupLocal); } public GroupLocalEntity? GetGroupById(int groupId) { GroupLocalEntity? grouplocal = LocalStaticData.groups.Where(x => x.ID == groupId).FirstOrDefault(); if (grouplocal == null) return null; return grouplocal; } } }