Studety/Demo/Data/Repository/GroupRepositoryImpl.cs
2024-10-18 09:49:19 +03:00

45 lines
1.1 KiB
C#

using Demo.Data.LocalData;
using Demo.domain.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Demo.Data.Repository
{
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
public class GroupRepositoryImpl
{
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
public void AddGroup(GroupLocalEntity newGroup)
{
LocalStaticData.groups.Add(newGroup);
}
public void UpdateGroupName(int groupId, string newName)
{
var group = LocalStaticData.groups.FirstOrDefault(g => g.Id == groupId);
if (group != null)
{
group.Name = newName;
}
}
public GroupLocalEntity GetGroupById(int groupId)
{
return LocalStaticData.groups.FirstOrDefault(g => g.Id == groupId);
}
private static string GetDebuggerDisplay()
{
return $"GroupRepository with {LocalStaticData.groups.Count} groups";
}
internal void AddGroup(Group group)
{
throw new NotImplementedException();
}
}
}