2024-11-01 09:41:07 +00:00
|
|
|
|
using System.Diagnostics;
|
2024-10-21 11:56:16 +00:00
|
|
|
|
using Zurnal.Date.Repository;
|
2024-11-01 09:41:07 +00:00
|
|
|
|
using Zurnal.RemaDateBase.DateDao;
|
|
|
|
|
using System.Text.RegularExpressions;
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
2024-10-23 08:14:10 +00:00
|
|
|
|
namespace Zurnal.Data.Repository
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
|
|
|
|
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
|
|
|
|
|
public class GroupRepositoryImpl : IGroupRepository
|
|
|
|
|
{
|
2024-11-01 09:41:07 +00:00
|
|
|
|
public List<GroupDao> AllGroup => GroupDao.Name.ToList();
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
2024-11-01 09:41:07 +00:00
|
|
|
|
public IEnumerable<GroupDao> GetAllGroups()
|
2024-11-02 07:50:36 +00:00
|
|
|
|
{
|
|
|
|
|
return GroupDao.Name;
|
|
|
|
|
}
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
2024-11-01 09:41:07 +00:00
|
|
|
|
public void AddGroup(GroupDao group)
|
|
|
|
|
{
|
|
|
|
|
if (group == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(group));
|
|
|
|
|
}
|
|
|
|
|
GroupDao.Name.Add(group);
|
|
|
|
|
}
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
2024-11-01 09:41:07 +00:00
|
|
|
|
public void UpdateGroupName(int groupId, string name)
|
2024-11-02 07:50:36 +00:00
|
|
|
|
{
|
|
|
|
|
var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
|
|
|
|
|
if (group != null)
|
|
|
|
|
{
|
|
|
|
|
group.GroupName = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
2024-11-02 07:50:36 +00:00
|
|
|
|
public bool UpdateGroupById(int groupId, GroupDao updatedGroup)
|
|
|
|
|
{
|
|
|
|
|
var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
|
|
|
|
|
if (group != null)
|
|
|
|
|
{
|
|
|
|
|
group.GroupName = updatedGroup.GroupName;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
|
|
|
|
private static string GetDebuggerDisplay()
|
|
|
|
|
{
|
2024-11-02 07:50:36 +00:00
|
|
|
|
return $"GroupRepository with {GroupDao.Name.Count} groups";
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-01 09:41:07 +00:00
|
|
|
|
public bool RemoveGroupById(int groupId)
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-11-02 07:50:36 +00:00
|
|
|
|
var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
|
2024-11-01 09:41:07 +00:00
|
|
|
|
if (group != null)
|
|
|
|
|
{
|
2024-11-02 07:50:36 +00:00
|
|
|
|
GroupDao.Name.Remove(group);
|
2024-11-01 09:41:07 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-01 09:41:07 +00:00
|
|
|
|
public IEnumerable<GroupDao> AllGroups()
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-11-02 07:50:36 +00:00
|
|
|
|
return GroupDao.Name.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id });
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 07:50:36 +00:00
|
|
|
|
public void DeleteGroup(int id)
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-11-02 07:50:36 +00:00
|
|
|
|
var group = GroupDao.Name.FirstOrDefault(g => g.Id == id);
|
2024-11-01 09:41:07 +00:00
|
|
|
|
if (group != null)
|
|
|
|
|
{
|
2024-11-02 07:50:36 +00:00
|
|
|
|
GroupDao.Name.Remove(group);
|
2024-11-01 09:41:07 +00:00
|
|
|
|
}
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
2024-11-01 07:49:39 +00:00
|
|
|
|
|
2024-11-02 07:50:36 +00:00
|
|
|
|
bool IGroupRepository.AddGroup(GroupDao newGroup)
|
2024-11-01 07:49:39 +00:00
|
|
|
|
{
|
2024-11-02 07:50:36 +00:00
|
|
|
|
throw new NotImplementedException();
|
2024-11-01 07:49:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-01 09:41:07 +00:00
|
|
|
|
public void AddGroupFromRegex(Group group)
|
2024-11-01 07:49:39 +00:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 07:50:36 +00:00
|
|
|
|
public GroupDao GetGroupById(int id)
|
2024-11-01 07:49:39 +00:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 07:50:36 +00:00
|
|
|
|
public void UpdateGroup(GroupDao group)
|
2024-11-01 07:49:39 +00:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|