using System.Text.RegularExpressions;
using Zurnal.Data.Repository;
using Zurnal.Date.Repository;
using Zurnal.RemaDateBase.DateDao;
namespace Zurnal.Domain.UseCase
{
    public class GroupUseCase : IGroupRepository
    {
        private List<GroupDao> _groups = new List<GroupDao>();
        private UserRepositoryImpl _repositoryUserImpl;
        private GroupRepositoryImpl _repositoryGroupImpl;

        public List<GroupDao> AllGroup => throw new NotImplementedException();


        public List<GroupDao> GetAllGroups() => _repositoryGroupImpl.GetAllGroups()
    .Select(it => new GroupDao { Id = it.Id, GroupName = it.GroupName }).ToList();

        public GroupUseCase(UserRepositoryImpl repositoryImpl, GroupRepositoryImpl repositoryGroupImpl)
        {
            _repositoryUserImpl = repositoryImpl;
            _repositoryGroupImpl = repositoryGroupImpl;
        }

        public void AddGroup(GroupDao group)
        {
            _repositoryGroupImpl.AddGroup(group: group);
        }

        public void UpdateGroupName(int groupId, string newName)
{
    _repositoryGroupImpl.UpdateGroupName(groupId, newName);
}

        public IEnumerable<GroupDao> AllGroups()
        {
            throw new NotImplementedException();
        }

        public bool RemoveGroupById(int groupID)
{
    var group = _repositoryGroupImpl.GetGroupById(groupID);
    if (group == null)
    {
        return false; 
    }
    _repositoryGroupImpl.DeleteGroup(groupID);
    return true; 
}

        public bool UpdateGroupById(int groupID, GroupDao updatedGroup)
        {
            throw new NotImplementedException();
        }

        IEnumerable<GroupDao> IGroupRepository.GetAllGroups() 
{
    return _repositoryGroupImpl.GetAllGroups()
        .Select(it => new GroupDao { Id = it.Id, GroupName = it.GroupName, Users = it.Users })
        .ToList();
}

        public void AddGroupFromRegex(System.Text.RegularExpressions.Group group)
        {
            throw new NotImplementedException();
        }

    public GroupDao GetGroupById(int id)
    {
        return _groups.FirstOrDefault(g => g.Id == id);
    }


        public void UpdateGroup(GroupDao group)
        {
            throw new NotImplementedException();
        }

        public void DeleteGroup(int id)
        {
            throw new NotImplementedException();
        }

        IEnumerable<Group> IGroupRepository.AllGroups()
        {
            throw new NotImplementedException();
        }

        bool IGroupRepository.AddGroup(GroupDao newGroup)
        {
            throw new NotImplementedException();
        }
    }
}