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>()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -83,7 +84,38 @@ namespace BMA.EHR.Application.Repositories
|
|||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<Profile>().AsQueryable();
|
||||
var data = _dbContext.Set<Profile>().AsQueryable()
|
||||
.Where(x => x.ProfileType == "officer");
|
||||
|
||||
|
||||
if (citizenId != null)
|
||||
data = data.Where(x => x.CitizenId!.Contains(citizenId));
|
||||
|
||||
if (firstName != null)
|
||||
data = data.Where(x => x.FirstName!.Contains(firstName));
|
||||
|
||||
if (lastName != null)
|
||||
data = data.Where(x => x.LastName!.Contains(lastName));
|
||||
|
||||
data = data.Include(x => x.Prefix)
|
||||
.Include(x => x.Position)
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PosNo);
|
||||
|
||||
return await data.ToListAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<Profile>> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<Profile>().AsQueryable()
|
||||
.Where(x => x.ProfileType == "employee");
|
||||
|
||||
|
||||
if (citizenId != null)
|
||||
|
|
@ -96,6 +128,8 @@ namespace BMA.EHR.Application.Repositories
|
|||
data = data.Where(x => x.LastName!.Contains(lastName));
|
||||
|
||||
data = data.Include(x => x.Prefix);
|
||||
//.Include(x => x.PosNoEmployee);
|
||||
|
||||
|
||||
return await data.ToListAsync();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue