using System.Collections.Generic;
using System.Threading.Tasks;
using Lada.Framework.Data.Enums;
using Lada.Framework.Data.Domains.Cms;
using Lada.Framework.Data.Repositories;
using Microsoft.EntityFrameworkCore;
using ladaexpress.vn.Infrastructures.Stores;

namespace ladaexpress.vn.Infrastructures.Services
{
    public interface IScriptConfigService
    {
        Task<List<string>> GetScriptsByPosition(ScriptPosition position);
    }

    public class ScriptConfigService : IScriptConfigService
    {
        public Task<List<string>> GetScriptsByPosition(ScriptPosition position)
        {
            var scripts = ScriptConfigStore.AllScripts
                .Where(x => x.IsActive && x.Position == position)
                .Select(x => x.ScriptContent)
                .ToList();
            return Task.FromResult(scripts);
        }
    }
}