2024-10-21 12:41:56 +00:00
|
|
|
|
using Demo.Data.Exceptions;
|
|
|
|
|
using Demo.Data.LocalData;
|
2024-10-25 08:47:11 +00:00
|
|
|
|
using Demo.Data.RemoteData.RemoteDataBase.DAO;
|
|
|
|
|
using Demo.Data.Repository;
|
2024-10-21 12:41:56 +00:00
|
|
|
|
using Demo.domain.Models;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2024-10-25 08:47:11 +00:00
|
|
|
|
public class GroupRepositoryImpl: IGroupRepository
|
2024-10-21 12:41:56 +00:00
|
|
|
|
{
|
|
|
|
|
private List<GroupLocalEntity> _groups = LocalStaticData.groups;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public GroupLocalEntity? GetGroupById(int groupId)
|
|
|
|
|
{
|
|
|
|
|
foreach (var group in _groups)
|
|
|
|
|
{
|
|
|
|
|
if (group.Id == groupId)
|
|
|
|
|
{
|
|
|
|
|
return group;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Метод для получения всех групп
|
|
|
|
|
public List<GroupLocalEntity> GetAllGroups() => _groups;
|
|
|
|
|
|
|
|
|
|
// Метод для добавления новой группы
|
|
|
|
|
public void AddGroup(GroupLocalEntity group)
|
|
|
|
|
{
|
|
|
|
|
group.Id = _groups.Any() ? _groups.Max(g => g.Id) + 1 : 1;
|
|
|
|
|
_groups.Add(group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Метод для обновления существующей группы
|
|
|
|
|
public void UpdateGroup(GroupLocalEntity group)
|
|
|
|
|
{
|
|
|
|
|
var existingGroup = GetGroupById(group.Id);
|
|
|
|
|
if (existingGroup == null) throw new GroupNotFoundException(group.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveGroupById(GroupLocalEntity group)
|
|
|
|
|
{
|
|
|
|
|
var existingGroup = GetGroupById(group.Id);
|
|
|
|
|
if (existingGroup == null) throw new GroupNotFoundException(group.Id);
|
|
|
|
|
if (_groups.Contains(existingGroup))
|
|
|
|
|
{
|
|
|
|
|
_groups.Remove(existingGroup);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-25 08:47:11 +00:00
|
|
|
|
|
|
|
|
|
public List<GroupLocalEntity> GetAllGroup()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool RemoveGroupById(int groupID)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IGroupRepository.AddGroup(GroupLocalEntity newGroup)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<GroupDao> GetAllGroupDao()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool RemoveGroupByIdDao(int groupID)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UpdateGroupById(int groupID, GroupDao updatedGroup)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GroupDao GetGroupByIdDao(int groupID)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AddGroup(GroupDao newGroup)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UpdateGroupByIdDao(int groupID, GroupDao updatedGroup)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AddGroupDao(GroupDao newGroup)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2024-10-21 12:41:56 +00:00
|
|
|
|
}
|