using Zurnal.RemaDateBase.DateDao;
using Microsoft.Extensions.DependencyInjection;
using Group = System.Text.RegularExpressions.Group;

namespace Zurnal.Date.Repository
{
    internal interface IGroupRepository
    {
        List<GroupDao> AllGroup { get; }

        public IEnumerable<GroupDao> AllGroups()
        {
            return GroupDao.Name.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id });
        }
        public bool RemoveGroupById(int groupId)
        {
            var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
            if (group != null)
            {
                GroupDao.Name.Remove(group);
                return true;
            }
            return false;
        }
        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;
}

public void DeleteGroup(int id)
        {
            var group = GroupDao.Name.FirstOrDefault(g => g.Id == id);
            if (group != null)
            {
                GroupDao.Name.Remove(group);
            }
        }
        void AddGroupFromRegex(Group group); 
        public GroupDao GetGroupById(int id);
        IEnumerable<GroupDao> GetAllGroups();
public void UpdateGroupName(int groupId, string name)
{
    var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId);
    if (group != null)
    {
        group.GroupName = name; 
    }
}
    }

    internal class ServiceConfiguration
    {
        public static void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<RemoteDateBaseContext>()
                    .AddScoped<IGroupRepository>();
        }
    }
}