permission พ้นจากราชการ
This commit is contained in:
parent
f8c62a1cde
commit
114ef1c01e
4 changed files with 147 additions and 4 deletions
|
|
@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection.Metadata;
|
||||
|
|
@ -39,6 +40,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public RetirementDeceasedController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
|
|
@ -46,7 +48,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IConfiguration configuration,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
|
|
@ -55,6 +58,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -542,6 +546,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
[HttpPut("detail/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDetail([FromBody] RetirementDeceasedAddNotiPersonRequest req, Guid id)
|
||||
{
|
||||
var action = "UPDATE";
|
||||
var system = "SYS_PASSAWAY";
|
||||
var getPermission = await _permission.GetPermissionAPIAsync(action, system);
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var attrPrivilege = jsonData["result"]?.ToString();
|
||||
var retirementDeceased = await _context.RetirementDeceaseds.AsQueryable()
|
||||
.Include(x => x.RetirementDeceasedNotis)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
|
@ -615,6 +628,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
[HttpDelete("detail/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteDetail(Guid id)
|
||||
{
|
||||
var action = "DELETE";
|
||||
var system = "SYS_PASSAWAY";
|
||||
var getPermission = await _permission.GetPermissionAPIAsync(action, system);
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var attrPrivilege = jsonData["result"]?.ToString();
|
||||
var retirementDeceasedNoti = await _context.RetirementDeceasedNotis.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (retirementDeceasedNoti == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue