no message

This commit is contained in:
Kittapath 2024-05-23 17:07:55 +07:00
parent 63b02dcc4c
commit afe16503ee
17 changed files with 36169 additions and 139 deletions

View file

@ -10,7 +10,9 @@ using BMA.EHR.Infrastructure.Persistence;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
@ -28,12 +30,14 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
private readonly MinIODisciplineService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly NotificationRepository _repositoryNoti;
private readonly IConfiguration _configuration;
public DisciplineComplaint_AppealController(DisciplineDbContext context,
NotificationRepository repositoryNoti,
ApplicationDBContext contextMain,
MinIODisciplineService documentService,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
{
// _repository = repository;
_context = context;
@ -41,6 +45,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
_repositoryNoti = repositoryNoti;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -48,6 +53,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private static string StatusDisciplineComplaintAppeal(string value)
{
switch (value)
@ -76,10 +82,24 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
[HttpGet("user")]
public async Task<ActionResult<ResponseObject>> GetDisciplineUser(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "")
{
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var profile = _contextMain.Profiles.FirstOrDefault(x => x.KeycloakId == userId);
if (profile == null)
var id = "";
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<dynamic>(_result);
if (org == null || org.result == null)
return Success(new { data = new List<dynamic>(), total = 0 });
id = org.result.profileId;
}
if (id == "")
return Success(new { data = new List<dynamic>(), total = 0 });
var data_search = (from x in _context.DisciplineComplaint_Appeals
where x.Title.Contains(keyword) ||
x.Description.Contains(keyword) ||
@ -87,7 +107,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
x.CaseNumber.Contains(keyword) ||
x.Fullname.Contains(keyword) ||
x.CitizenId.Contains(keyword)
where x.ProfileId == profile.Id
where x.ProfileId == Guid.Parse(id)
select x).ToList();
if (status.Trim().ToUpper() != "ALL")
data_search = data_search.Where(x => x.Status == status).ToList();