Files
EmailBill/Repository/BudgetArchiveRepository.cs

34 lines
1.1 KiB
C#
Raw Normal View History

namespace Repository;
public interface IBudgetArchiveRepository : IBaseRepository<BudgetArchive>
{
Task<BudgetArchive?> GetArchiveAsync(long budgetId, int year, int month);
Task<List<BudgetArchive>> GetListAsync(int year, int month);
}
public class BudgetArchiveRepository(
IFreeSql freeSql
) : BaseRepository<BudgetArchive>(freeSql), IBudgetArchiveRepository
{
public async Task<BudgetArchive?> GetArchiveAsync(long budgetId, int year, int month)
{
return await FreeSql.Select<BudgetArchive>()
.Where(a => a.BudgetId == budgetId &&
a.Year == year &&
a.Month == month)
.ToOneAsync();
}
public async Task<List<BudgetArchive>> GetListAsync(int year, int month)
{
return await FreeSql.Select<BudgetArchive>()
.Where(
a => a.BudgetType == BudgetPeriodType.Month &&
a.Year == year &&
a.Month == month ||
a.BudgetType == BudgetPeriodType.Year &&
a.Year == year
)
.ToListAsync();
}
}