This commit is contained in:
Userok 2024-11-02 10:50:36 +03:00
parent d8b97b4d47
commit 023f6a3f3f
4 changed files with 48 additions and 62 deletions

View File

@ -32,26 +32,32 @@ namespace Zurnal.Data.Repository
var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId); var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
if (group != null) if (group != null)
{ {
group.Name = name; group.GroupName = name;
} }
} }
public GroupDao GetGroupById(int id) public bool UpdateGroupById(int groupId, GroupDao updatedGroup)
{ {
return GroupDao.groups.FirstOrDefault(g => g.Id == id); var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
if (group != null)
{
group.GroupName = updatedGroup.GroupName;
return true;
}
return false;
} }
private static string GetDebuggerDisplay() private static string GetDebuggerDisplay()
{ {
return $"GroupRepository with {GroupDao.groups.Count} groups"; return $"GroupRepository with {GroupDao.Name.Count} groups";
} }
public bool RemoveGroupById(int groupId) public bool RemoveGroupById(int groupId)
{ {
var group = GroupDao.groups.FirstOrDefault(g => g.Id == groupId); var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
if (group != null) if (group != null)
{ {
GroupDao.groups.Remove(group); GroupDao.Name.Remove(group);
return true; return true;
} }
return false; return false;
@ -59,61 +65,41 @@ namespace Zurnal.Data.Repository
public IEnumerable<GroupDao> AllGroups() public IEnumerable<GroupDao> AllGroups()
{ {
return GroupDao.groups.Select(g => new GroupDao { GroupName = g.Name, Id = g.Id }); return GroupDao.Name.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id });
}
public bool UpdateGroupById(int groupId, GroupDao updatedGroup)
{
var group = GroupDao.groups.FirstOrDefault(g => g.Id == groupId);
if (group != null)
{
group.Name = updatedGroup.GroupName;
return true;
}
return false;
}
public void UpdateGroup(GroupDao group)
{
var existingGroup = GroupDao.groups.FirstOrDefault(g => g.Id == group.Id);
if (existingGroup != null)
{
existingGroup.Name = group.GroupName;
}
} }
public void DeleteGroup(int id) public void DeleteGroup(int id)
{ {
var group = GroupDao.groups.FirstOrDefault(g => g.Id == id); var group = GroupDao.Name.FirstOrDefault(g => g.Id == id);
if (group != null) if (group != null)
{ {
GroupDao.groups.Remove(group); GroupDao.Name.Remove(group);
} }
} }
public bool AddGroup(GroupDao newGroup)
{
if (newGroup == null)
{
throw new ArgumentNullException(nameof(newGroup));
}
GroupDao.groups.Add(newGroup);
return true;
}
public void AddGroupFromRegex(Group group)
{
throw new NotImplementedException();
}
IEnumerable<Group> IGroupRepository.AllGroups() IEnumerable<Group> IGroupRepository.AllGroups()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
bool IGroupRepository.AddGroup(GroupDao newGroup)
{
throw new NotImplementedException();
}
public void AddGroupFromRegex(Group group) public void AddGroupFromRegex(Group group)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public GroupDao GetGroupById(int id)
{
throw new NotImplementedException();
}
public void UpdateGroup(GroupDao group)
{
throw new NotImplementedException();
}
} }
} }

View File

@ -2,7 +2,7 @@
{ {
public class GroupDao public class GroupDao
{ {
internal static IEnumerable<GroupDao> Name; internal static List<GroupDao> Name = new List<GroupDao>();
public int Id { get; set; } public int Id { get; set; }
public required string GroupName { get; set; } public required string GroupName { get; set; }

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Zurnal")] [assembly: System.Reflection.AssemblyCompanyAttribute("Zurnal")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d72fa803793c5d114c3eabb8fe2de04cd2042db1")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d8b97b4d4726ad4a4fb1b1f71d1f4e9c62ebd29b")]
[assembly: System.Reflection.AssemblyProductAttribute("Zurnal")] [assembly: System.Reflection.AssemblyProductAttribute("Zurnal")]
[assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")] [assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
7af827faec1f5dd576cc86e70a9c41ec992b431c5545340778b3dec093fd4ac1 c3dcf515a535c8feb2557d6f2ba5b36f9feac86b0ec88244007d55a701c20bcf