แก้ 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

@ -90,7 +90,7 @@ namespace BMA.EHR.DisciplineComplaint_Channel.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);
return Success(data);
}
@ -133,11 +133,11 @@ namespace BMA.EHR.DisciplineComplaint_Channel.Service.Controllers
{
var data = await _context.DisciplineComplaint_Channels.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 dupicateData = await _context.DisciplineComplaint_Channels.Where(x => x.Id != id && x.Name == req.name).FirstOrDefaultAsync();
if (dupicateData != null)
return Error(new Exception("ชื่อประเภทนี้มีอยู่ในระบบแล้ว"), (int)StatusCodes.Status400BadRequest);
return Error(new Exception("ชื่อประเภทนี้มีอยู่ในระบบแล้ว"), StatusCodes.Status400BadRequest);
data.Name = req.name;
data.LastUpdateFullName = FullName ?? "System Administrator";
@ -160,7 +160,7 @@ namespace BMA.EHR.DisciplineComplaint_Channel.Service.Controllers
{
var data = await _context.DisciplineComplaint_Channels.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);
_context.DisciplineComplaint_Channels.Remove(data);
await _context.SaveChangesAsync();
return Success();