permission พ้นจากราชการ
This commit is contained in:
parent
f8c62a1cde
commit
114ef1c01e
4 changed files with 147 additions and 4 deletions
|
|
@ -9,6 +9,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.Security.Claims;
|
||||
|
|
@ -29,13 +30,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public RetirementOutController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration)
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
|
|
@ -43,6 +46,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -334,6 +338,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
[HttpPut("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> Put([FromBody] RetirementOutEditRequest req, Guid id)
|
||||
{
|
||||
var action = "UPDATE";
|
||||
var system = "SYS_DISMISS";
|
||||
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 uppdated = await _context.RetirementOuts
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
|
|
@ -393,6 +406,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
[HttpDelete("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||
{
|
||||
var action = "DELETE";
|
||||
var system = "SYS_DISMISS";
|
||||
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 deleted = await _context.RetirementOuts.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
|
|
@ -414,6 +436,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
[HttpPost("report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] RetirementProfileRequest req)
|
||||
{
|
||||
var action = "CREATE";
|
||||
var system = "SYS_DISMISS";
|
||||
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();
|
||||
foreach (var item in req.Id)
|
||||
{
|
||||
var uppdated = await _context.RetirementOuts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue