using System.Linq;
using StubCore.Entities;
using System.Collections.Generic;

namespace StubCore.Plugins.DataCollector
{
    public class NodesCollector : FrontCollector
    {
        private readonly string sourceName;
        private readonly string nodesFolder;

        public NodesCollector(string name, string folder) : base(name, folder)
        {
            sourceName = name;
            nodesFolder = folder;
        }

        public List<Node> GetNodesforProfile(int id)
        {
            var _fileList = new List<Node>();
            var _list = GetFiles<Node>();

            if (_list.Count > 0)
            {
                _fileList = (_list.Where(node => node.profileID == id)).ToList<Node>();

                if (_fileList.Count == 0)
                {
                    _logger.NoItemsFoundForProfile(id, nodesFolder);
                }
            }
            else
            {
                _logger.ItemsListNotExists(nodesFolder);
            }

            return _fileList;

        }

        public int GetNodesCount(int profileID)
        {
            var _list = GetNodesforProfile(profileID);
            return _list.Count;
        }
    }
}
