apiคนพิการ
This commit is contained in:
parent
be27aa4d33
commit
1d4043a50e
37 changed files with 9794 additions and 298 deletions
65
Services/DisableService.cs
Normal file
65
Services/DisableService.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models.Disables;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||
{
|
||||
public class DisableService
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public DisableService(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public int GetExamCount(string citizenId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = _context.Disables.AsQueryable()
|
||||
.Where(x => x.CitizenId == citizenId)
|
||||
.Count();
|
||||
|
||||
return count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> GetExamAttributeAsync(Guid period, Guid exam)
|
||||
{
|
||||
try
|
||||
{
|
||||
var payment = await _context.DisablePayments.AsQueryable()
|
||||
.Include(x => x.Disable)
|
||||
.ThenInclude(x => x.PeriodExam)
|
||||
.Where(x => x.Disable.Id == exam)
|
||||
.Where(x => x.Disable.PeriodExam.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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue