using AsbCloudApp.Services; using AsbCloudDb.Model; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace AsbCloudInfrastructure.Repository { #nullable enable public class CrudWellRelatedCacheServiceBase : CrudCacheRepositoryBase, IRepositoryWellRelated where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated where TEntity : class, IId, IWellRelated { public CrudWellRelatedCacheServiceBase(IAsbCloudDbContext context, IMemoryCache memoryCache) : base(context, memoryCache) { } public CrudWellRelatedCacheServiceBase(IAsbCloudDbContext context, IMemoryCache memoryCache, Func, IQueryable> makeQuery) : base(context, memoryCache, makeQuery) { } public async Task?> GetByIdWellAsync(int idWell, CancellationToken token) { var cache = await GetCacheAsync(token); var dtos = cache .Where(e => e.IdWell == idWell) .ToList(); return dtos; } public async Task?> GetByIdWellAsync(IEnumerable idsWells, CancellationToken token) { if (!idsWells.Any()) return Enumerable.Empty(); var cache = await GetCacheAsync(token); var dtos = cache .Where(e => idsWells.Contains(e.IdWell)) .ToList(); return dtos; } } #nullable disable }