Demo/Data/Repository/GroupRepositoryImpl.cs

31 lines
973 B
C#
Raw Normal View History

2024-10-17 11:46:19 +00:00
using Demo.Domain.Models;
using Demo.Data.LocalData;
namespace Demo.Data.Repository
{
public class GroupRepositoryImpl
{
// public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
public GroupRepositoryImpl() {
GetAllGroups = LocalStaticData.groups;
}
public List<GroupLocalEntity> GetAllGroups
{ get; set; }
public void CreateNewGroup(GroupLocalEntity groupLocalEntity)
{
GetAllGroups.Add(groupLocalEntity);
}
public GroupLocalEntity? UpdateUserById(GroupLocalEntity groupUpdateLocalEntity)
{
int index = GetAllGroups.FindIndex(x => x.ID == groupUpdateLocalEntity.ID);
if (index == -1) return null;
GetAllGroups[index].Name = groupUpdateLocalEntity.Name;
Console.WriteLine($"Обновленный Name: {GetAllGroups[index].Name}");
return GetAllGroups[index];
}
}
}