แก้ Defect

This commit is contained in:
Suphonchai Phoonsawat 2023-11-24 14:21:33 +07:00
parent 5ae67ee02e
commit 0096e6dd5b
8 changed files with 184 additions and 97 deletions

View file

@ -137,7 +137,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (_data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
var disciplineInvestigateDocComplaints = new List<dynamic>();
foreach (var doc in _data.DisciplineInvestigateDocComplaints)
@ -187,9 +187,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
{
var data = await _context.DisciplineInvestigates.Include(x => x.DisciplineInvestigate_Profiles).Where(x => x.Id == id).FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
data.Title = req.title;
data.Description = req.description;
@ -273,7 +273,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (_data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
var disciplineInvestigateDocs = new List<dynamic>();
foreach (var doc in _data.DisciplineInvestigateDocs)
@ -335,9 +335,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
data.InvestigationDetail = req.investigationDetail.Trim().ToUpper();
data.InvestigationDetailOther = req.investigationDetailOther;
@ -390,11 +390,11 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถยุติเรื่องได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถยุติเรื่องได้"), StatusCodes.Status500InternalServerError);
if (data.InvestigationStatusResult == null || data.InvestigationStatusResult.Trim().ToUpper() != "NO_CAUSE")
return Error(new Exception("ไม่สามารถยุติเรื่องได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถยุติเรื่องได้"), StatusCodes.Status500InternalServerError);
data.Status = "STOP";
await _context.SaveChangesAsync();
@ -416,9 +416,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถส่งต่อไปสืบสวนได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถส่งต่อไปสืบสวนได้"), StatusCodes.Status500InternalServerError);
data.Status = "SEND_INVESTIGATE";
await _context.SaveChangesAsync();
@ -440,9 +440,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "STOP")
return Error(new Exception("รายการนี้ยังไม่ถูกยุติเรื่อง"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("รายการนี้ยังไม่ถูกยุติเรื่อง"), StatusCodes.Status500InternalServerError);
data.Status = "NEW";
await _context.SaveChangesAsync();
@ -464,9 +464,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
@ -514,9 +514,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
var dataDoc = data.DisciplineInvestigate_Docs.Where(x => x.Document.Id == docId).FirstOrDefault();
if (dataDoc != null)
{
@ -543,9 +543,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
@ -596,9 +596,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
var dataDoc = data.DisciplineInvestigate_DocComplaints.Where(x => x.Document.Id == docId).FirstOrDefault();
if (dataDoc != null)
{
@ -629,9 +629,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
@ -679,9 +679,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
if (data.Status.Trim().ToUpper() != "NEW")
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), StatusCodes.Status500InternalServerError);
var dataDoc = data.DisciplineInvestigateRelevant_Docs.Where(x => x.Document.Id == docId).FirstOrDefault();
if (dataDoc != null)
{