HerculesCRUE_Commons-ED-MA/src/Hercules.CommonsEDMA.OAI_PMH/OAI_PMH/Models/OAIPMH/SetRepository.cs
using OaiPmhNet;
using OaiPmhNet.Models;
using System.Collections.Generic;
using System.Linq;

namespace OAI_PMH.Models.OAIPMH
{
    class SetRepository : ISetRepository
    {
        private readonly IOaiConfiguration _configuration;
        private readonly IList<Set> _sets;

        public SetRepository(IOaiConfiguration configuration)
        {
            _configuration = configuration;
            _sets = new List<Set>();
            List<string> setNameList = new()
            {
                "Persona",
                "Organizacion",
                "Proyecto",
                "PRC",
                "AutorizacionProyecto",
                "Invencion",
                "Grupo"
            };

            foreach (string setName in setNameList)
            {
                Set set = new()
                {
                    Spec = setName,
                    Name = setName,
                    Description = setName
                };
                _sets.Add(set);
            }
        }

        public SetContainer GetSets(ArgumentContainer arguments, IResumptionToken resumptionToken = null)
        {
            SetContainer container = new();
            IQueryable<Set> sets = _sets.AsQueryable().OrderBy(s => s.Name);
            int totalCount = sets.Count();
            container.Sets = sets;
            return container;
        }
    }
}
