add authname
This commit is contained in:
parent
fc747782d4
commit
3bb7864789
6 changed files with 62 additions and 58 deletions
|
|
@ -122,25 +122,25 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
if (_data == null)
|
||||
return Error("ไม่พบข้อมูลในระบบ");
|
||||
|
||||
if (_data.AuthName == null || _data.AuthName == "")
|
||||
{
|
||||
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
_data.AuthName = org.result.name == null ? "" : org.result.name;
|
||||
_data.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (_data.AuthName == null || _data.AuthName == "")
|
||||
// {
|
||||
// var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
||||
// using (var client = new HttpClient())
|
||||
// {
|
||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
// var _res = await client.SendAsync(_req);
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
// if (_res.IsSuccessStatusCode)
|
||||
// {
|
||||
// var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
// _data.AuthName = org.result.name == null ? "" : org.result.name;
|
||||
// _data.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||
// await _context.SaveChangesAsync();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
var data = await _context.Disables.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
|
|
@ -159,8 +159,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
EndDate = p.PeriodExam.RegisterEndDate == null ? "" : (p.PeriodExam.RegisterEndDate.Value.ToThaiFullDate3()),
|
||||
AuthName = p.AuthName,
|
||||
AuthPosition = p.AuthPosition
|
||||
AuthName = p.PeriodExam.AuthName,
|
||||
AuthPosition = p.PeriodExam.AuthPosition
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue