49 lines
No EOL
1.5 KiB
C#
49 lines
No EOL
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using BMA.EHR.Recruit.Service.Data;
|
|
using BMA.EHR.Recruit.Service.Models.Recruits;
|
|
|
|
namespace BMA.EHR.Recruit.Service.Services
|
|
{
|
|
public class RecruitService
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
|
|
public RecruitService(ApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<string> GetExamAttributeAsync(Guid period, Guid exam)
|
|
{
|
|
try
|
|
{
|
|
var payment = await _context.RecruitPayments.AsQueryable()
|
|
.Include(x => x.Recruit)
|
|
.ThenInclude(x => x.RecruitImport)
|
|
.Where(x => x.Recruit.Id == exam)
|
|
.Where(x => x.Recruit.RecruitImport.Id == period)
|
|
.FirstOrDefaultAsync();
|
|
|
|
return payment != null ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ";
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public bool CheckValidCertificate(DateTime certDate, int nextYear = 5)
|
|
{
|
|
var valid = true;
|
|
if (DateTime.Now.Date > certDate.Date.AddYears(nextYear))
|
|
valid = false;
|
|
|
|
return valid;
|
|
}
|
|
|
|
}
|
|
} |