edit query

This commit is contained in:
kittapath 2025-10-09 21:43:25 +07:00
parent 9e8fe1b30a
commit 4ba48d0e70
2 changed files with 27 additions and 64 deletions

View file

@ -9,6 +9,7 @@ using BMA.EHR.Domain.Models.Organizations;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Nest;
using Newtonsoft.Json;
namespace BMA.EHR.Application.Repositories
@ -532,7 +533,7 @@ namespace BMA.EHR.Application.Repositories
nodeId = nodeId,
role = role,
revisionId = revisionId,
reqNode = reqNode,
reqNode = reqNode,
reqNodeId = reqNodeId
};
@ -686,7 +687,7 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task<List<GetProfileByKeycloakIdRootDto>> GetEmployeeByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId )
public async Task<List<GetProfileByKeycloakIdRootDto>> GetEmployeeByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId)
{
try
{
@ -720,7 +721,7 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task<List<SearchProfileDto>> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, string? role, string? nodeId, int? node)
public async Task<dynamic> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node)
{
try
{
@ -734,41 +735,25 @@ namespace BMA.EHR.Application.Repositories
role = role,
nodeId = nodeId,
node = node,
page = page,
pageSize = pageSize,
};
var profiles = new List<SearchProfileDto>();
var profiles = new List<dynamic>();
var total = 0;
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<SearchProfileResultDto>(apiResult);
var raw = JsonConvert.DeserializeObject<dynamic>(apiResult);
if (raw != null && raw.Result != null)
{
profiles.AddRange(raw.Result);
profiles.AddRange(raw.Result.data);
total = raw.Result.total;
}
}
return profiles;
//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();
return new { data = profiles, total = total };
}
catch
{
@ -776,7 +761,7 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task<List<SearchProfileDto>> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName, string accessToken, string? role, string? nodeId, int? node)
public async Task<dynamic> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node)
{
try
{
@ -790,41 +775,25 @@ namespace BMA.EHR.Application.Repositories
role = role,
nodeId = nodeId,
node = node,
page = page,
pageSize = pageSize,
};
var profiles = new List<SearchProfileDto>();
var profiles = new List<dynamic>();
var total = 0;
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<SearchProfileResultDto>(apiResult);
var raw = JsonConvert.DeserializeObject<dynamic>(apiResult);
if (raw != null && raw.Result != null)
{
profiles.AddRange(raw.Result);
profiles.AddRange(raw.Result.data);
total = raw.Result.total;
}
}
return profiles;
//var data = _dbContext.Set<Profile>().AsQueryable()
// .Where(x => x.ProfileType == "employee");
//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.PosNoEmployee);
//return await data.ToListAsync();
return new { data = profiles, total = total };
}
catch
{