แจ้งเตือนร้องทุกข์

This commit is contained in:
Kittapath 2023-12-21 08:41:40 +07:00
parent a0b7be76ae
commit b8c5f88142
11 changed files with 3533 additions and 458 deletions

View file

@ -24,15 +24,21 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
public class DisciplineComplaint_AppealController : BaseController
{
private readonly DisciplineDbContext _context;
private readonly ApplicationDBContext _contextMain;
private readonly MinIODisciplineService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly NotificationRepository _repositoryNoti;
public DisciplineComplaint_AppealController(DisciplineDbContext context,
NotificationRepository repositoryNoti,
ApplicationDBContext contextMain,
MinIODisciplineService documentService,
IHttpContextAccessor httpContextAccessor)
{
// _repository = repository;
_context = context;
_contextMain = contextMain;
_repositoryNoti = repositoryNoti;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
}
@ -56,6 +62,10 @@ 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)
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) ||
@ -63,7 +73,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
x.CaseNumber.Contains(keyword) ||
x.Fullname.Contains(keyword) ||
x.CitizenId.Contains(keyword)
where x.CreatedUserId == UserId
where x.ProfileId == profile.Id
select x).ToList();
if (status.Trim().ToUpper() != "ALL")
data_search = data_search.Where(x => x.Status == status).ToList();
@ -240,6 +250,14 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
}
}
}
await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
$"มีคำขอยื่นอุทธรณ์/ร้องทุกข์จาก {req.Fullname}",
$"มีคำขอยื่นอุทธรณ์/ร้องทุกข์จาก {req.Fullname}",
"",
true,
true
);
await _context.SaveChangesAsync();
return Success(disciplineComplaint_Appeal.Id);
}
@ -414,6 +432,14 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
LastUpdatedAt = DateTime.Now,
};
await _context.DisciplineComplaint_Appeal_Historys.AddAsync(disciplineComplaint_Appeal_History);
await _repositoryNoti.PushNotificationAsync(
data.ProfileId,
$"มีการแก้ไขสถานะคำขออุทธรณ์/ร้องทุกข์จาก {data.Fullname}",
$"มีการแก้ไขสถานะคำขออุทธรณ์/ร้องทุกข์จาก {data.Fullname}",
"",
true,
true
);
}
data.Status = req.Status.Trim().ToUpper();
data.Type = req.Type.Trim().ToUpper();