using System.Linq; using System.Threading.Tasks; using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.AndroidApkVersionAgg; using CompanyManagment.App.Contracts.AndroidApkVersion; using Microsoft.EntityFrameworkCore; namespace CompanyManagment.EFCore.Repository; public class AndroidApkVersionRepository:RepositoryBase,IAndroidApkVersionRepository { private readonly CompanyContext _companyContext; public AndroidApkVersionRepository( CompanyContext companyContext) : base(companyContext) { _companyContext = companyContext; } public IQueryable GetActives(ApkType apkType) { return _companyContext.AndroidApkVersions.Where(x => x.IsActive == IsActive.True && x.ApkType == apkType); } public async Task GetLatestActiveVersionPath(ApkType apkType) { return (await _companyContext.AndroidApkVersions.OrderByDescending(x=>x.CreationDate).FirstOrDefaultAsync(x => x.IsActive == IsActive.True && x.ApkType == apkType)).Path; } public AndroidApkVersion GetLatestActive(ApkType apkType) { return _companyContext.AndroidApkVersions .Where(x => x.IsActive == IsActive.True && x.ApkType == apkType) .OrderByDescending(x => x.CreationDate) .FirstOrDefault(); } }