Files
Backend-Api/CompanyManagment.EFCore/Repository/AndroidApkVersionRepository.cs

36 lines
1.3 KiB
C#

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<long, AndroidApkVersion>,IAndroidApkVersionRepository
{
private readonly CompanyContext _companyContext;
public AndroidApkVersionRepository( CompanyContext companyContext) : base(companyContext)
{
_companyContext = companyContext;
}
public IQueryable<AndroidApkVersion> GetActives(ApkType apkType)
{
return _companyContext.AndroidApkVersions.Where(x => x.IsActive == IsActive.True && x.ApkType == apkType);
}
public async Task<string> 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();
}
}