Studety/Demo/Data/Repository/GroupRepositoryImpl.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2024-10-18 06:12:15 +00:00
using Demo.Data.LocalData;
using Demo.domain.Models;
using System;
using System.Collections.Generic;
2024-10-18 06:49:19 +00:00
using System.Diagnostics;
2024-10-18 06:12:15 +00:00
using System.Linq;
namespace Demo.Data.Repository
{
2024-10-18 06:49:19 +00:00
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
2024-10-18 06:12:15 +00:00
public class GroupRepositoryImpl
{
2024-10-18 06:49:19 +00:00
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)
2024-10-18 06:12:15 +00:00
{
2024-10-18 06:49:19 +00:00
group.Name = newName;
2024-10-18 06:12:15 +00:00
}
2024-10-18 06:49:19 +00:00
}
2024-10-18 06:12:15 +00:00
2024-10-18 06:49:19 +00:00
public GroupLocalEntity GetGroupById(int groupId)
{
return LocalStaticData.groups.FirstOrDefault(g => g.Id == groupId);
}
private static string GetDebuggerDisplay()
2024-10-18 06:12:15 +00:00
{
2024-10-18 06:49:19 +00:00
return $"GroupRepository with {LocalStaticData.groups.Count} groups";
}
internal void AddGroup(Group group)
{
throw new NotImplementedException();
2024-10-18 06:12:15 +00:00
}
}
2024-10-18 06:49:19 +00:00
}