using AsbCloudApp.Data; using AsbCloudApp.Services; using AsbCloudDb.Model; using AsbCloudInfrastructure.Repository; using DocumentFormat.OpenXml.InkML; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services { public class FileCategoryService : CrudCacheServiceBase, IFileCategoryService { private readonly IAsbCloudDbContext db; public FileCategoryService(IAsbCloudDbContext context) : base(context) { this.db = context; } public async Task> GetWellCategoryAsync(CancellationToken token) { var data = await (from category in db.FileCategories where category.Id >= 10000 && category.Id <= 20000 select new FileCategoryDto { Id = category.Id, Name = category.Name, ShortName = category.ShortName }) .ToListAsync(token) .ConfigureAwait(false); return data.ToList(); } public override async Task GetOrDefaultAsync(int id, CancellationToken token) { var entity = await db.FileCategories .FirstOrDefaultAsync(x => x.Id == id) .ConfigureAwait(false); var dto = Convert(entity); return dto; } } }