api รายงาน + Reopen Issue
This commit is contained in:
parent
d5a78f2d0f
commit
48892556fd
10 changed files with 662 additions and 10 deletions
|
|
@ -439,6 +439,35 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return 0;
|
||||
}
|
||||
|
||||
public async Task<int> GetSumApproveLeaveByTypeAndRangeForUser(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||
.Where(x => x.Type.Id == leaveTypeId)
|
||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||
.Where(x => x.LeaveStatus == "APPROVE")
|
||||
.ToListAsync();
|
||||
|
||||
if (data.Count > 0)
|
||||
return data.Sum(x => x.LeaveTotal);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public async Task<int> GetCountApproveLeaveByTypeAndRangeForUser(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||
.Where(x => x.Type.Id == leaveTypeId)
|
||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||
.Where(x => x.LeaveStatus == "APPROVE")
|
||||
.ToListAsync();
|
||||
|
||||
return data.Count;
|
||||
}
|
||||
|
||||
public async Task<int> GetSumRejectLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.Leave.Commons;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||
|
|
@ -52,5 +53,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public async Task<LeaveType?> GetLeaveTypeByCodeAsync(string code)
|
||||
{
|
||||
return await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Code == code);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,6 +155,17 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
return data.Count;
|
||||
}
|
||||
|
||||
public async Task<List<ProcessUserTimeStamp>> GetTimeStampHistoryByRangeForUserAsync(Guid userId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
.Where(x => x.KeycloakUserId == userId)
|
||||
.Where(u => u.CheckIn.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<List<ProcessUserTimeStamp>> GetTimeStampHistoryForAdminAsync(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue