using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using StubCore.Entities;
using StubCore.Plugins.DataOperations;
using StubCore.Plugins.FileOperations;

namespace StubCore.Plugins.Migration
{
    public class MigrationOperations
    {
        private readonly string _extension;
        private readonly string _folder = "json";
        private readonly string _file = "profiles";
        private readonly string _filesFolder = "profileFiles";
        

        private readonly FileDataOperations _fileOperations;

        public MigrationOperations()
        {
            _fileOperations = new FileDataOperations();
            _extension = "." + Configuration.Configuration.DataType;
        }

        public List<JsonProfile> GetProfiles()
        {
            var _json = new JsonOperations();

            var profiles = _fileOperations.GetFile(_folder + "/" + _file + _extension);
            return _json.GetDataObject<List<JsonProfile>>(profiles);
        }

        public bool ScanFolders()
        {
            var notEmpty = false;

            if (_fileOperations.DirectoryExists(_folder))
            {
                notEmpty = true;
            }

            return notEmpty;
        }

        public bool ScanFiles()
        {
            return _fileOperations.FileExists(_folder + "/" + _file + _extension);
        }
    }
}
