hrms-api-backend/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs
2023-08-17 10:46:30 +07:00

63 lines
1.5 KiB
C#

using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Retirement;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Application.Repositories.Reports
{
public class RetireReportRepository
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
#endregion
#region " Constructor and Destructor "
public RetireReportRepository(IApplicationDBContext dbContext)
{
_dbContext = dbContext;
}
#endregion
#region " Methods "
public async Task<List<RetirementPeriod>> GetListRetirePeriodAsync()
{
try
{
// 1. query
var data = await _dbContext.Set<RetirementPeriod>()
.Include(x => x.RetirementPeriodHistorys)
.Include(x => x.RetirementProfiles)
.ThenInclude(x => x.Profile)
.ToListAsync();
// 2. data not found throw exception
// 3. Load Report File
return data;
}
catch
{
throw;
}
}
#endregion
}
}