1278 lines
73 KiB
C#
1278 lines
73 KiB
C#
using BMA.EHR.Application.Repositories;
|
|
using BMA.EHR.Application.Repositories.MessageQueue;
|
|
using BMA.EHR.Discipline.Service.Requests;
|
|
using BMA.EHR.Domain.Common;
|
|
using BMA.EHR.Domain.Models.Discipline;
|
|
using BMA.EHR.Domain.Shared;
|
|
using BMA.EHR.Infrastructure.Persistence;
|
|
// using BMA.EHR.Placement.Service.Requests;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using System.Security.Claims;
|
|
|
|
namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|
{
|
|
[Route("api/v{version:apiVersion}/discipline/disciplinary")]
|
|
[ApiVersion("1.0")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
[Authorize]
|
|
[SwaggerTag("ระบบวินัยเรื่องสอบสวน")]
|
|
public class DisciplineDisciplinaryController : BaseController
|
|
{
|
|
private readonly DisciplineDbContext _context;
|
|
private readonly MinIODisciplineService _documentService;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
public DisciplineDisciplinaryController(DisciplineDbContext context,
|
|
MinIODisciplineService documentService,
|
|
IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
// _repository = repository;
|
|
_context = context;
|
|
_documentService = documentService;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
}
|
|
|
|
#region " Properties "
|
|
|
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// list รายการวินัยเรื่องสอบสวน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet()]
|
|
public async Task<ActionResult<ResponseObject>> GetDisciplineDisciplinary(int page = 1, int pageSize = 25, string keyword = "")
|
|
{
|
|
var data_search = (from x in _context.DisciplineDisciplinarys
|
|
where x.Title.Contains(keyword) ||
|
|
x.DisciplinaryFaultLevel.Contains(keyword) ||
|
|
x.DisciplinaryCaseFault.Contains(keyword)
|
|
select x).ToList();
|
|
var data = data_search
|
|
.Select(x => new
|
|
{
|
|
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
|
Title = x.Title,//ชื่อเรื่อง
|
|
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
|
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
|
DisciplinaryFaultLevel = x.DisciplinaryFaultLevel,//ระดับโทษความผิด
|
|
DisciplinaryCaseFault = x.DisciplinaryCaseFault,//กรณีความผิด
|
|
Status = x.Status,//สถานะหรือผลการสอบสวน
|
|
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสอบสวน
|
|
})
|
|
.OrderByDescending(x => x.CreatedAt)
|
|
.Skip((page - 1) * pageSize)
|
|
.Take(pageSize)
|
|
.ToList();
|
|
return Success(new { data, total = data_search.Count() });
|
|
}
|
|
|
|
/// <summary>
|
|
/// get รายการวินัยเรื่องร้องเรียน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("complaint/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetByDisciplineDisciplinaryComplaint(Guid id)
|
|
{
|
|
var _data = await _context.DisciplineDisciplinarys
|
|
.Select(x => new
|
|
{
|
|
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
|
IdInvestigate = x.DisciplineInvestigate.Id,//id ข้อมูลเรื่องสืบสวน
|
|
IdComplaint = x.DisciplineInvestigate.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
|
|
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
|
Persons = x.DisciplineDisciplinary_ProfileComplaintInvestigates.Select(p => new
|
|
{
|
|
Id = p.Id,
|
|
Idcard = p.CitizenId,
|
|
Name = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
|
Prefix = p.Prefix,
|
|
FirstName = p.FirstName,
|
|
LastName = p.LastName,
|
|
Position = p.Position,
|
|
PositionLevel = p.PositionLevel,
|
|
Salary = p.Salary,
|
|
PersonId = p.PersonId,
|
|
PosNo = p.PosNo,
|
|
Organization = p.Organization,
|
|
}),//รายการข้อมูลบุคลผู้ถูกสืบสวน
|
|
OrganizationId = x.Organization,//id หน่วยงานกรณี type เป็นหน่วยงาน
|
|
ConsideredAgency = x.ConsideredAgency,//หน่วยงานที่พิจารณา จะเปลี่ยนไปตามผู้ถูกร้องดูรายละเอียดด้านล่าง
|
|
Title = x.Title,//ชื่อเรื่อง
|
|
Description = x.Description,//รายละเอียด
|
|
DateReceived = x.DateReceived,//วันที่รับเรื่อง
|
|
LevelConsideration = x.LevelConsideration,//ระดับการพัฒนา
|
|
DateConsideration = x.DateConsideration,//วันที่กำหนดพิจารณา
|
|
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
|
DateNotification = x.DateNotification,//วันแจ้งเตือนล่วงหน้า
|
|
ComplaintFrom = x.ComplaintFrom,//รับเรื่องสืบสวนจาก
|
|
Appellant = x.Appellant,//ผู้ถูกสืบสวน
|
|
Result = x.ResultComplaint,//ผลการตรวจสอบ
|
|
Status = x.Status,//สถานะเรื่องสืบสวน
|
|
DisciplineDisciplinaryDocComplaintInvestigates = x.DisciplineDisciplinary_DocComplaintInvestigates.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
})
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (_data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
|
|
var disciplineDisciplinaryDocComplaintInvestigates = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinaryDocComplaintInvestigates)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id)
|
|
};
|
|
disciplineDisciplinaryDocComplaintInvestigates.Add(_doc);
|
|
}
|
|
var data = new
|
|
{
|
|
_data.Id,
|
|
_data.IdInvestigate,
|
|
_data.IdComplaint,
|
|
_data.RespondentType,
|
|
_data.Persons,
|
|
_data.OrganizationId,
|
|
_data.ConsideredAgency,
|
|
_data.Title,
|
|
_data.Description,
|
|
_data.DateReceived,
|
|
_data.LevelConsideration,
|
|
_data.DateConsideration,
|
|
_data.OffenseDetails,
|
|
_data.DateNotification,
|
|
_data.ComplaintFrom,
|
|
_data.Appellant,
|
|
_data.Result,
|
|
_data.Status,
|
|
disciplineDisciplinaryDocComplaintInvestigates,
|
|
};
|
|
return Success(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// แก้ไขรายการวินัยเรื่องร้องเรียน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("complaint/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UpdateDisciplineDisciplinaryComplaint([FromBody] DisciplineDisciplinaryComplaintRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys.Include(x => x.DisciplineDisciplinary_ProfileComplaintInvestigates).Where(x => x.Id == id).FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
data.Title = req.title;
|
|
data.Description = req.description;
|
|
data.OffenseDetails = req.offenseDetails.Trim().ToUpper();
|
|
data.LastUpdateFullName = FullName ?? "System Administrator";
|
|
data.LastUpdateUserId = UserId ?? "";
|
|
data.LastUpdatedAt = DateTime.Now;
|
|
_context.DisciplineDisciplinary_ProfileComplaintInvestigates.RemoveRange(data.DisciplineDisciplinary_ProfileComplaintInvestigates);
|
|
if (data.RespondentType.Trim().ToUpper() == "PERSON")
|
|
{
|
|
foreach (var item in req.persons)
|
|
{
|
|
data.DisciplineDisciplinary_ProfileComplaintInvestigates.Add(
|
|
new DisciplineDisciplinary_ProfileComplaintInvestigate
|
|
{
|
|
CitizenId = item.idcard,
|
|
Prefix = item.prefix,
|
|
FirstName = item.firstName,
|
|
LastName = item.lastName,
|
|
Organization = item.organization,
|
|
Position = item.position,
|
|
PositionLevel = item.positionLevel,
|
|
Salary = item.salary,
|
|
PersonId = item.personId,
|
|
PosNo = item.posNo,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
}
|
|
);
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success(data.Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// get รายการวินัยเรื่องสืบสวน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("investigate/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetByDisciplineDisciplinaryInvestigate(Guid id)
|
|
{
|
|
var _data = await _context.DisciplineDisciplinarys
|
|
.Select(x => new
|
|
{
|
|
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
|
IdInvestigate = x.DisciplineInvestigate.Id,//id ข้อมูลเรื่องสืบสวน
|
|
IdComplaint = x.DisciplineInvestigate.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
|
|
InvestigationDetail = x.InvestigationDetail,
|
|
InvestigationDetailOther = x.InvestigationDetailOther,
|
|
InvestigationDateStart = x.InvestigationDateStart,
|
|
InvestigationDateEnd = x.InvestigationDateEnd,
|
|
InvestigationDescription = x.InvestigationDescription,
|
|
InvestigationStatusResult = x.InvestigationStatusResult,
|
|
InvestigationCauseText = x.InvestigationCauseText,
|
|
Status = x.Status,//สถานะเรื่องสืบสวน
|
|
Result = x.Result,//ผลการตรวจสอบ
|
|
Director = x.DisciplineDisciplinary_DirectorInvestigates.Select(d => new
|
|
{
|
|
Id = d.Id,
|
|
DirectorId = d.DisciplineDirector.Id,
|
|
Prefix = d.DisciplineDirector.Prefix,
|
|
FirstName = d.DisciplineDirector.FirstName,
|
|
LastName = d.DisciplineDirector.LastName,
|
|
Position = d.DisciplineDirector.Position,
|
|
Email = d.DisciplineDirector.Email,
|
|
Duty = "",
|
|
Phone = d.DisciplineDirector.Phone,
|
|
Total = d.DisciplineDirector.DisciplineDisciplinary_DirectorInvestigates.Count(),
|
|
}).ToList(),
|
|
DisciplineDisciplinaryDocInvestigates = x.DisciplineDisciplinary_DocInvestigates.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
DisciplineDisciplinaryDocInvestigateRelevants = x.DisciplineDisciplinary_DocInvestigateRelevants.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
})
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (_data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
|
|
var disciplineDisciplinaryDocInvestigates = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinaryDocInvestigates)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id)
|
|
};
|
|
disciplineDisciplinaryDocInvestigates.Add(_doc);
|
|
}
|
|
|
|
var disciplineDisciplinaryDocInvestigateRelevants = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinaryDocInvestigateRelevants)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id)
|
|
};
|
|
disciplineDisciplinaryDocInvestigateRelevants.Add(_doc);
|
|
}
|
|
var data = new
|
|
{
|
|
_data.Id,
|
|
_data.IdInvestigate,
|
|
_data.IdComplaint,
|
|
_data.InvestigationDetail,
|
|
_data.InvestigationDetailOther,
|
|
_data.InvestigationDateStart,
|
|
_data.InvestigationDateEnd,
|
|
_data.InvestigationDescription,
|
|
_data.InvestigationStatusResult,
|
|
_data.InvestigationCauseText,
|
|
_data.Status,
|
|
_data.Result,
|
|
_data.Director,
|
|
disciplineDisciplinaryDocInvestigates,
|
|
disciplineDisciplinaryDocInvestigateRelevants,
|
|
};
|
|
return Success(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// แก้ไขรายการวินัยเรื่องสืบสวน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("investigate/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UpdateDisciplineDisciplinaryInvestigate([FromBody] DisciplineDisciplinaryInvestigateRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DirectorInvestigates)
|
|
.ThenInclude(x => x.DisciplineDirector)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
data.InvestigationDetail = req.investigationDetail.Trim().ToUpper();
|
|
data.InvestigationDetailOther = req.investigationDetailOther;
|
|
data.InvestigationDateStart = req.investigationDateStart;
|
|
data.InvestigationDateEnd = req.investigationDateEnd;
|
|
data.InvestigationDescription = req.investigationDescription;
|
|
data.InvestigationStatusResult = req.investigationStatusResult.Trim().ToUpper();
|
|
data.InvestigationCauseText = req.investigationCauseText.Trim().ToUpper();
|
|
data.Result = req.result;
|
|
data.LastUpdateFullName = FullName ?? "System Administrator";
|
|
data.LastUpdateUserId = UserId ?? "";
|
|
data.LastUpdatedAt = DateTime.Now;
|
|
_context.DisciplineDisciplinary_DirectorInvestigates.RemoveRange(data.DisciplineDisciplinary_DirectorInvestigates);
|
|
foreach (var item in req.directors)
|
|
{
|
|
var director = await _context.DisciplineDirectors.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == item);
|
|
if (director != null)
|
|
{
|
|
data.DisciplineDisciplinary_DirectorInvestigates.Add(
|
|
new DisciplineDisciplinary_DirectorInvestigate
|
|
{
|
|
DisciplineDirector = director,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
}
|
|
);
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success(data.Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// get รายการวินัยเรื่องสอบสวน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetByDisciplineDisciplinary(Guid id)
|
|
{
|
|
var _data = await _context.DisciplineDisciplinarys
|
|
.Select(x => new
|
|
{
|
|
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
|
IdInvestigate = x.DisciplineInvestigate.Id,//id ข้อมูลเรื่องสืบสวน
|
|
IdComplaint = x.DisciplineInvestigate.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
|
|
DisciplinaryWitnesses = x.DisciplinaryWitnesses,
|
|
DisciplinaryRecordAccuser = x.DisciplinaryRecordAccuser,
|
|
DisciplinarySummaryEvidence = x.DisciplinarySummaryEvidence,
|
|
DisciplinaryRefLaw = x.DisciplinaryRefLaw,
|
|
DisciplinaryFaultLevel = x.DisciplinaryFaultLevel,
|
|
DisciplinaryInvestigateAt = x.DisciplinaryInvestigateAt,
|
|
DisciplinaryCaseFault = x.DisciplinaryCaseFault,
|
|
DisciplinaryDateEvident = x.DisciplinaryDateEvident,
|
|
DisciplinaryDateAllegation = x.DisciplinaryDateAllegation,
|
|
Result = x.Result,
|
|
Director = x.DisciplineDisciplinary_DirectorInvestigates.Select(d => new
|
|
{
|
|
Id = d.Id,
|
|
DirectorId = d.DisciplineDirector.Id,
|
|
Prefix = d.DisciplineDirector.Prefix,
|
|
FirstName = d.DisciplineDirector.FirstName,
|
|
LastName = d.DisciplineDirector.LastName,
|
|
Position = d.DisciplineDirector.Position,
|
|
Email = d.DisciplineDirector.Email,
|
|
Duty = "",
|
|
Phone = d.DisciplineDirector.Phone,
|
|
Total = d.DisciplineDirector.DisciplineDisciplinary_DirectorInvestigates.Count(),
|
|
}).ToList(),
|
|
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
|
Persons = x.DisciplineDisciplinary_ProfileComplaintInvestigates.Select(p => new
|
|
{
|
|
Id = p.Id,
|
|
Idcard = p.CitizenId,
|
|
Name = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
|
Prefix = p.Prefix,
|
|
FirstName = p.FirstName,
|
|
LastName = p.LastName,
|
|
Position = p.Position,
|
|
PositionLevel = p.PositionLevel,
|
|
Salary = p.Salary,
|
|
PersonId = p.PersonId,
|
|
PosNo = p.PosNo,
|
|
Organization = p.Organization,
|
|
}),//รายการข้อมูลบุคลผู้ถูกสืบสวน
|
|
OrganizationId = x.Organization,//id หน่วยงานกรณี type เป็นหน่วยงาน
|
|
DisciplineDisciplinary_DocSummaryEvidences = x.DisciplineDisciplinary_DocSummaryEvidences.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
DisciplineDisciplinary_DocRecordAccusers = x.DisciplineDisciplinary_DocRecordAccusers.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
DisciplineDisciplinary_DocWitnessess = x.DisciplineDisciplinary_DocWitnessess.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
DisciplineDisciplinary_DocOthers = x.DisciplineDisciplinary_DocOthers.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
})
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (_data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
|
|
var disciplineDisciplinary_DocSummaryEvidences = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinary_DocSummaryEvidences)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id)
|
|
};
|
|
disciplineDisciplinary_DocSummaryEvidences.Add(_doc);
|
|
}
|
|
var disciplineDisciplinary_DocRecordAccusers = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinary_DocRecordAccusers)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id)
|
|
};
|
|
disciplineDisciplinary_DocRecordAccusers.Add(_doc);
|
|
}
|
|
var disciplineDisciplinary_DocWitnessess = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinary_DocWitnessess)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id)
|
|
};
|
|
disciplineDisciplinary_DocWitnessess.Add(_doc);
|
|
}
|
|
var disciplineDisciplinary_DocOthers = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinary_DocOthers)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id)
|
|
};
|
|
disciplineDisciplinary_DocOthers.Add(_doc);
|
|
}
|
|
var data = new
|
|
{
|
|
_data.Id,
|
|
_data.IdInvestigate,
|
|
_data.IdComplaint,
|
|
_data.DisciplinaryWitnesses,
|
|
_data.DisciplinaryRecordAccuser,
|
|
_data.DisciplinarySummaryEvidence,
|
|
_data.DisciplinaryRefLaw,
|
|
_data.DisciplinaryFaultLevel,
|
|
_data.DisciplinaryInvestigateAt,
|
|
_data.DisciplinaryCaseFault,
|
|
_data.DisciplinaryDateEvident,
|
|
_data.DisciplinaryDateAllegation,
|
|
_data.Result,
|
|
_data.Director,
|
|
_data.RespondentType,
|
|
_data.Persons,
|
|
_data.OrganizationId,
|
|
disciplineDisciplinary_DocSummaryEvidences,
|
|
disciplineDisciplinary_DocRecordAccusers,
|
|
disciplineDisciplinary_DocWitnessess,
|
|
disciplineDisciplinary_DocOthers,
|
|
};
|
|
return Success(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// แก้ไขรายการวินัยเรื่องสอบสวน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UpdateDisciplineDisciplinary([FromBody] DisciplineDisciplinaryRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DirectorInvestigates)
|
|
.ThenInclude(x => x.DisciplineDirector)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
data.DisciplinaryWitnesses = req.DisciplinaryWitnesses;
|
|
data.DisciplinaryRecordAccuser = req.DisciplinaryRecordAccuser;
|
|
data.DisciplinarySummaryEvidence = req.DisciplinarySummaryEvidence;
|
|
data.DisciplinaryRefLaw = req.DisciplinaryRefLaw;
|
|
data.DisciplinaryFaultLevel = req.DisciplinaryFaultLevel;
|
|
data.DisciplinaryInvestigateAt = req.DisciplinaryInvestigateAt;
|
|
data.DisciplinaryCaseFault = req.DisciplinaryCaseFault;
|
|
data.DisciplinaryDateEvident = req.DisciplinaryDateEvident;
|
|
data.DisciplinaryDateAllegation = req.DisciplinaryDateAllegation;
|
|
data.Result = req.Result;
|
|
data.LastUpdateFullName = FullName ?? "System Administrator";
|
|
data.LastUpdateUserId = UserId ?? "";
|
|
data.LastUpdatedAt = DateTime.Now;
|
|
_context.DisciplineDisciplinary_DirectorInvestigates.RemoveRange(data.DisciplineDisciplinary_DirectorInvestigates);
|
|
foreach (var item in req.directors)
|
|
{
|
|
var director = await _context.DisciplineDirectors.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == item);
|
|
if (director != null)
|
|
{
|
|
data.DisciplineDisciplinary_DirectorInvestigates.Add(
|
|
new DisciplineDisciplinary_DirectorInvestigate
|
|
{
|
|
DisciplineDirector = director,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
}
|
|
);
|
|
}
|
|
}
|
|
data.Organization = req.organizationId;
|
|
data.RespondentType = req.respondentType;
|
|
_context.DisciplineDisciplinary_ProfileComplaintInvestigates.RemoveRange(data.DisciplineDisciplinary_ProfileComplaintInvestigates);
|
|
if (data.RespondentType.Trim().ToUpper() == "PERSON")
|
|
{
|
|
foreach (var item in req.persons)
|
|
{
|
|
data.DisciplineDisciplinary_ProfileComplaintInvestigates.Add(
|
|
new DisciplineDisciplinary_ProfileComplaintInvestigate
|
|
{
|
|
CitizenId = item.idcard,
|
|
Prefix = item.prefix,
|
|
FirstName = item.firstName,
|
|
LastName = item.lastName,
|
|
Organization = item.organization,
|
|
Position = item.position,
|
|
PositionLevel = item.positionLevel,
|
|
Salary = item.salary,
|
|
PersonId = item.personId,
|
|
PosNo = item.posNo,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
}
|
|
);
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success(data.Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ยุติเรื่อง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("reject/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> RejectDisciplineDisciplinary(Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถยุติเรื่องได้"), (int)StatusCodes.Status500InternalServerError);
|
|
if (data.InvestigationStatusResult == null || data.InvestigationStatusResult.Trim().ToUpper() != "NO_CAUSE")
|
|
return Error(new Exception("ไม่สามารถยุติเรื่องได้"), (int)StatusCodes.Status500InternalServerError);
|
|
data.Status = "STOP";
|
|
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งเรื่องสอบสวน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("approve/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> ApproveDisciplineDisciplinary(Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถเสร็จสิ้นสอบสวนได้"), (int)StatusCodes.Status500InternalServerError);
|
|
data.Status = "DONE";
|
|
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ยกเลิกการยุติเรื่อง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("resume/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> ResumeDisciplineDisciplinary(Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "STOP")
|
|
return Error(new Exception("รายการนี้ยังไม่ถูกยุติเรื่อง"), (int)StatusCodes.Status500InternalServerError);
|
|
data.Status = "NEW";
|
|
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// อัพไฟล์เอกสารสืบสวนวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinaryInvestigate([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
|
{
|
|
foreach (var file in Request.Form.Files)
|
|
{
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
|
var _doc = await _context.Documents.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
|
if (_doc != null)
|
|
{
|
|
var disciplineDisciplinary_DocInvestigate = new DisciplineDisciplinary_DocInvestigate
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocInvestigates.AddAsync(disciplineDisciplinary_DocInvestigate);
|
|
}
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบไฟล์เอกสารสืบสวนวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("file/{id:guid}/{docId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineDisciplinaryInvestigate(Guid id, Guid docId)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocInvestigates)
|
|
.ThenInclude(x => x.Document)
|
|
.Include(x => x.DisciplineInvestigate)
|
|
.ThenInclude(x => x.DisciplineInvestigate_Docs)
|
|
.ThenInclude(x => x.Document)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
var dataDoc = data.DisciplineDisciplinary_DocInvestigates.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocInvestigates.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
var dataDocComplaint = data.DisciplineInvestigate.DisciplineInvestigate_Docs.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDocComplaint == null)
|
|
{
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// อัพไฟล์เอกสารร้องเรียนวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("complaint/file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinaryComplaint([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
|
{
|
|
foreach (var file in Request.Form.Files)
|
|
{
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
|
var _doc = await _context.Documents.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
|
if (_doc != null)
|
|
{
|
|
var disciplineDisciplinary_DocComplaintInvestigate = new DisciplineDisciplinary_DocComplaintInvestigate
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocComplaintInvestigates.AddAsync(disciplineDisciplinary_DocComplaintInvestigate);
|
|
}
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบไฟล์เอกสารร้องเรียนวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("complaint/file/{id:guid}/{docId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineDisciplinaryComplaint(Guid id, Guid docId)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocComplaintInvestigates)
|
|
.ThenInclude(x => x.Document)
|
|
.Include(x => x.DisciplineInvestigate)
|
|
.ThenInclude(x => x.DisciplineComplaint)
|
|
.ThenInclude(x => x.DisciplineComplaint_Docs)
|
|
.ThenInclude(x => x.Document)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
var dataDoc = data.DisciplineDisciplinary_DocComplaintInvestigates.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocComplaintInvestigates.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
var dataDocComplaint = data.DisciplineInvestigate.DisciplineComplaint.DisciplineComplaint_Docs.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDocComplaint == null)
|
|
{
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// อัพไฟล์เอกสารเกี่ยวข้องสืบสวนวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("relevant/file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinaryInvestigateRelevant([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
|
{
|
|
foreach (var file in Request.Form.Files)
|
|
{
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
|
var _doc = await _context.Documents.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
|
if (_doc != null)
|
|
{
|
|
var disciplineDisciplinary_DocInvestigateRelevant = new DisciplineDisciplinary_DocInvestigateRelevant
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocInvestigateRelevants.AddAsync(disciplineDisciplinary_DocInvestigateRelevant);
|
|
}
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบไฟล์เอกสารเกี่ยวข้องสืบสวนวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("relevant/file/{id:guid}/{docId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineDisciplinaryInvestigateRelevant(Guid id, Guid docId)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocInvestigateRelevants)
|
|
.ThenInclude(x => x.Document)
|
|
.Include(x => x.DisciplineInvestigate)
|
|
.ThenInclude(x => x.DisciplineInvestigateRelevant_Docs)
|
|
.ThenInclude(x => x.Document)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
var dataDoc = data.DisciplineDisciplinary_DocInvestigateRelevants.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocInvestigateRelevants.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
var dataDocComplaint = data.DisciplineInvestigate.DisciplineInvestigateRelevant_Docs.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDocComplaint == null)
|
|
{
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// อัพไฟล์หลักฐานสนับสนุนข้อกล่าวหา
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("summaryEvidence/file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinarySummaryEvidences([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
|
{
|
|
foreach (var file in Request.Form.Files)
|
|
{
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
|
var _doc = await _context.Documents.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
|
if (_doc != null)
|
|
{
|
|
var disciplineDisciplinary_DocSummaryEvidence = new DisciplineDisciplinary_DocSummaryEvidence
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocSummaryEvidences.AddAsync(disciplineDisciplinary_DocSummaryEvidence);
|
|
}
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบหลักฐานสนับสนุนข้อกล่าวหา
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("summaryEvidence/file/{id:guid}/{docId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineDisciplinarySummaryEvidences(Guid id, Guid docId)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocSummaryEvidences)
|
|
.ThenInclude(x => x.Document)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
var dataDoc = data.DisciplineDisciplinary_DocSummaryEvidences.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocSummaryEvidences.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// อัพไฟล์บันทึกถ้อยคำของผู้กล่าวหา
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("recordAccuser/file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinaryRecordAccusers([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
|
{
|
|
foreach (var file in Request.Form.Files)
|
|
{
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
|
var _doc = await _context.Documents.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
|
if (_doc != null)
|
|
{
|
|
var disciplineDisciplinary_DocRecordAccuser = new DisciplineDisciplinary_DocRecordAccuser
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocRecordAccusers.AddAsync(disciplineDisciplinary_DocRecordAccuser);
|
|
}
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบไฟล์บันทึกถ้อยคำของผู้กล่าวหา
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("recordAccuser/file/{id:guid}/{docId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineDisciplinaryRecordAccusers(Guid id, Guid docId)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocRecordAccusers)
|
|
.ThenInclude(x => x.Document)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
var dataDoc = data.DisciplineDisciplinary_DocRecordAccusers.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocRecordAccusers.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// อัพไฟล์พยานและการบันทึกถ้อยคำ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("witnesses/file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinaryWitnessess([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
|
{
|
|
foreach (var file in Request.Form.Files)
|
|
{
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
|
var _doc = await _context.Documents.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
|
if (_doc != null)
|
|
{
|
|
var disciplineDisciplinary_DocWitnesses = new DisciplineDisciplinary_DocWitnesses
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocWitnessess.AddAsync(disciplineDisciplinary_DocWitnesses);
|
|
}
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบไฟล์พยานและการบันทึกถ้อยคำ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("witnesses/file/{id:guid}/{docId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineDisciplinaryWitnessess(Guid id, Guid docId)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocWitnessess)
|
|
.ThenInclude(x => x.Document)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
var dataDoc = data.DisciplineDisciplinary_DocWitnessess.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocWitnessess.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// อัพไฟล์เอกสารหลักฐานอื่น ๆ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("other/file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinaryOther([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
|
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
|
{
|
|
foreach (var file in Request.Form.Files)
|
|
{
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
|
var _doc = await _context.Documents.AsQueryable()
|
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
|
if (_doc != null)
|
|
{
|
|
var disciplineDisciplinary_DocOther = new DisciplineDisciplinary_DocOther
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocOthers.AddAsync(disciplineDisciplinary_DocOther);
|
|
}
|
|
}
|
|
}
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบไฟล์เอกสารหลักฐานอื่น ๆ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("other/file/{id:guid}/{docId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineDisciplinaryOther(Guid id, Guid docId)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocOthers)
|
|
.ThenInclude(x => x.Document)
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
if (data.Status.Trim().ToUpper() != "NEW")
|
|
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
|
var dataDoc = data.DisciplineDisciplinary_DocOthers.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocOthers.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
|
}
|
|
}
|
|
}
|
|
}
|