using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XYY.Service.Standard.KnowledgeBase.Data;

namespace XYY.Service.Standard.KnowledgeBase
{
    public interface IKnowledgeSevice
    {
        Task<List<string>> GetDicts();
        Task<List<Model.KnowledgeBase>> GetFiles(string dictName);
        Task UpdateFile(Model.KnowledgeBase @base);

        Task Delete(int Id);
    }

    public class KnowledgeSevice : IKnowledgeSevice
    {
        IKnowledgeBaseRepository Repository;
        public KnowledgeSevice(IKnowledgeBaseRepository repository, ILogger<KnowledgeSevice> logger)
        {
            Repository = repository;
        }

        public async Task Delete(int Id)
        {
            await Repository.DeleteByIdAsync(Id);
        }

        public async Task<List<string>> GetDicts()
        {
            return await this.Repository.GetDicts();
        }

        public async Task<List<Model.KnowledgeBase>> GetFiles(string dictName)
        {
            return await this.Repository.GetFiles(dictName);
        }

        public async Task UpdateFile(Model.KnowledgeBase @base)
        {
            await this.Repository.UpdateFile(@base);
        }
    }
}
