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

namespace StubCore.Plugins.DataCollector
{
    public class FilesCollector : FrontCollector
    {

        private readonly string sourceName;
        private readonly string filesFolder;
        
        public FilesCollector(string name, string folder) : base(name, folder)
        {
            sourceName = name;
            filesFolder = folder;  
        }

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

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

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

            return _fileList;
        }

        public int GetFilesCount(int profileID)
        {
            var _list = GetFilesForProfile(profileID);
            return _list.Count;
        }

    }
}
