นับวันหยุด ต้องตัดเสาร์ อาทิตย์ออก
This commit is contained in:
parent
91c479ef9e
commit
9263d880be
1 changed files with 8 additions and 4 deletions
|
|
@ -49,12 +49,16 @@ namespace BMA.EHR.Application.Repositories.MetaData
|
||||||
|
|
||||||
public async Task<int> GetHolidayCountAsync(DateTime startDate, DateTime endDate, string category = "NORMAL")
|
public async Task<int> GetHolidayCountAsync(DateTime startDate, DateTime endDate, string category = "NORMAL")
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<Holiday>().AsQueryable()
|
var query = _dbContext.Set<Holiday>().AsQueryable()
|
||||||
.Where(x => x.Category == category)
|
.Where(x => x.Category == category)
|
||||||
.Where(x => x.HolidayDate.Date >= startDate && x.HolidayDate.Date <= endDate)
|
.Where(x => x.HolidayDate.Date >= startDate && x.HolidayDate.Date <= endDate);
|
||||||
.CountAsync();
|
|
||||||
|
|
||||||
return data;
|
if (category == "NORMAL")
|
||||||
|
query = query.Where(x => x.HolidayDate.DayOfWeek != DayOfWeek.Saturday && x.HolidayDate.DayOfWeek != DayOfWeek.Sunday);
|
||||||
|
else
|
||||||
|
query = query.Where(x => x.HolidayDate.DayOfWeek != DayOfWeek.Sunday);
|
||||||
|
|
||||||
|
return await query.CountAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DateTime> GetWeekEnd(DateTime startDate, DateTime endDate, string category = "NORMAL")
|
public List<DateTime> GetWeekEnd(DateTime startDate, DateTime endDate, string category = "NORMAL")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue