using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Repository;
using Microsoft.Extensions.Caching.Memory;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace AsbCloudInfrastructure.Services
{

    public class FileCategoryService : CrudCacheRepositoryBase<FileCategoryDto, FileCategory>, IFileCategoryService
    {
        public FileCategoryService(IAsbCloudDbContext context, IMemoryCache memoryCache)
            : base(context, memoryCache) { }

        //TODO: Перенести в сервис "дело скважины"
        public async Task<IEnumerable<FileCategoryDto>> GetWellCaseCategoriesAsync(CancellationToken token)
        {
            var cache = await GetCacheAsync(token)
                .ConfigureAwait(false);
            var dtos = cache
                .Where(f => f.Id >= 10000)
                .Where(f => f.Id <= 20000)
                .Select(Convert);

            return dtos;
        }
    }

}