Merge branch 'dev' into working
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 2m1s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 2m1s
This commit is contained in:
commit
c55648a3cc
4 changed files with 65 additions and 5 deletions
|
|
@ -187,6 +187,44 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
}
|
||||
}
|
||||
|
||||
private async Task<string> GetMyProfileIdAsync()
|
||||
{
|
||||
var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId";
|
||||
var response = await GetExternalAPIAsync(apiUrl, AccessToken!, _configuration["API_KEY"]!);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(response))
|
||||
return string.Empty;
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(response);
|
||||
if (org == null || org.result == null)
|
||||
return string.Empty;
|
||||
|
||||
return org.result.profileId ?? string.Empty;
|
||||
}
|
||||
|
||||
public async Task<int> DeleteAllMyNotificationsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var profileId = await GetMyProfileIdAsync();
|
||||
if (string.IsNullOrEmpty(profileId))
|
||||
return 0;
|
||||
|
||||
var notifications = await _dbContext.Set<Notification>()
|
||||
.Where(x => x.ReceiverUserId == Guid.Parse(profileId))
|
||||
.Where(x => x.DeleteDate == null)
|
||||
.ToListAsync();
|
||||
|
||||
_dbContext.Set<Notification>().RemoveRange(notifications);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return notifications.Count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, string Payload = "", string NotiLink = "", bool IsSendInbox = false, bool IsSendMail = false)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -184,6 +184,31 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบ Notification ทั้งหมดของ user ที่ login (Hard delete)
|
||||
/// </summary>
|
||||
/// <returns>จำนวนรายการที่ถูกลบ</returns>
|
||||
/// <response code="200">เมื่อทำการลบข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("my-notifications")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PermanentDeleteAllMyNotificationsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var affectedRows = await _notificationRepository.DeleteAllMyNotificationsAsync();
|
||||
|
||||
return Success(affectedRows);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -449,11 +449,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementOther.PositionLevelOld = org.result.posLevelName;
|
||||
retirementOther.PositionTypeOld = org.result.posTypeName;
|
||||
retirementOther.PositionNumberOld = org.result.posNo;
|
||||
retirementOther.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "\n") +
|
||||
(org.result.child3 == null ? "" : org.result.child3 + "\n") +
|
||||
(org.result.child2 == null ? "" : org.result.child2 + "\n") +
|
||||
(org.result.child1 == null ? "" : org.result.child1 + "\n") +
|
||||
(org.result.root == null ? "" : org.result.root);
|
||||
retirementOther.OrganizationOld = org.result.org ?? "";
|
||||
retirementOther.OrganizationPositionOld = org.result.position + "\n" +
|
||||
(retirementOther.PositionExecutiveOld == null ? "" : (retirementOther.positionExecutiveField == null ? retirementOther.PositionExecutiveOld + "\n" : retirementOther.PositionExecutiveOld + "(" + retirementOther.positionExecutiveField + ")" + "\n"))
|
||||
+ retirementOther.OrganizationOld;
|
||||
|
|
|
|||
|
|
@ -54,5 +54,6 @@ namespace BMA.EHR.Retirement.Service.Requests
|
|||
public DateTime? leaveDate { get; set; }
|
||||
public string? education { get; set; }
|
||||
public double? salary { get; set; }
|
||||
public string? org { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue