แก้ body จัดสรร
This commit is contained in:
parent
dce5aaf778
commit
a19712d2f3
1 changed files with 23 additions and 20 deletions
|
|
@ -123,7 +123,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPost()]
|
[HttpPost()]
|
||||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaManageRequest req)
|
public async Task<ActionResult<ResponseObject>> Post([FromBody] InsigniaManageRequest req)
|
||||||
{
|
{
|
||||||
var insignia = await _context.Insignias.AsQueryable()
|
var insignia = await _context.Insignias.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.Insignia);
|
.FirstOrDefaultAsync(x => x.Id == req.Insignia);
|
||||||
|
|
@ -187,8 +187,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPut("{id:length(36)}")]
|
[HttpPut("{insigniaManageId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> Put([FromForm] InsigniaManageRequest req, Guid insigniaManageId)
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] InsigniaManageRequest req, Guid insigniaManageId)
|
||||||
{
|
{
|
||||||
var insignia = await _context.Insignias.AsQueryable()
|
var insignia = await _context.Insignias.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.Insignia);
|
.FirstOrDefaultAsync(x => x.Id == req.Insignia);
|
||||||
|
|
@ -249,9 +249,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
LastUpdatedAt = p.LastUpdatedAt,
|
LastUpdatedAt = p.LastUpdatedAt,
|
||||||
CreatedAt = p.CreatedAt,
|
CreatedAt = p.CreatedAt,
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.ToListAsync();
|
||||||
if (insigniaManageOrg == null)
|
// if (insigniaManageOrg == null)
|
||||||
return Error(GlobalMessages.InsigniaManageOrgNotFound);
|
// return Error(GlobalMessages.InsigniaManageOrgNotFound);
|
||||||
return Success(insigniaManageOrg);
|
return Success(insigniaManageOrg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,9 +266,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
[HttpPost("org")]
|
[HttpPost("org")]
|
||||||
public async Task<ActionResult<ResponseObject>> PostOrganization([FromBody] InsigniaManageOrganizationRequest req)
|
public async Task<ActionResult<ResponseObject>> PostOrganization([FromBody] InsigniaManageOrganizationRequest req)
|
||||||
{
|
{
|
||||||
var organizationOrganization = await _context.OrganizationOrganizations.AsQueryable()
|
var organization = await _context.Organizations.AsQueryable()
|
||||||
|
.Include(x => x.OrganizationOrganization)
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.OrganizationOrganizationId);
|
.FirstOrDefaultAsync(x => x.Id == req.OrganizationOrganizationId);
|
||||||
if (organizationOrganization == null)
|
if (organization == null)
|
||||||
return Error(GlobalMessages.OrganizationNotFound);
|
return Error(GlobalMessages.OrganizationNotFound);
|
||||||
|
|
||||||
var insigniaManage = await _context.InsigniaManages.AsQueryable()
|
var insigniaManage = await _context.InsigniaManages.AsQueryable()
|
||||||
|
|
@ -277,13 +278,13 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.insigniaManageId);
|
.FirstOrDefaultAsync(x => x.Id == req.insigniaManageId);
|
||||||
if (insigniaManage == null)
|
if (insigniaManage == null)
|
||||||
return Error(GlobalMessages.InsigniaManageNotFound);
|
return Error(GlobalMessages.InsigniaManageNotFound);
|
||||||
var total = insigniaManage.InsigniaManageOrganiations.Where(x => x.OrganizationOrganization != organizationOrganization).Sum(x => x.Total);
|
var total = insigniaManage.InsigniaManageOrganiations.Where(x => x.OrganizationOrganization != organization.OrganizationOrganization).Sum(x => x.Total);
|
||||||
if (req.Total + total > insigniaManage.Total)
|
if (req.Total + total > insigniaManage.Total)
|
||||||
return Error(GlobalMessages.InsigniaManageOrgLimit);
|
return Error(GlobalMessages.InsigniaManageOrgLimit);
|
||||||
await _context.InsigniaManageOrganiations.AddAsync(
|
await _context.InsigniaManageOrganiations.AddAsync(
|
||||||
new InsigniaManageOrganiation
|
new InsigniaManageOrganiation
|
||||||
{
|
{
|
||||||
OrganizationOrganization = organizationOrganization,
|
OrganizationOrganization = organization.OrganizationOrganization,
|
||||||
Total = req.Total,
|
Total = req.Total,
|
||||||
InsigniaManage = insigniaManage,
|
InsigniaManage = insigniaManage,
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
|
|
@ -330,7 +331,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPut("org/{insigniaManageOrgId:length(36)}")]
|
[HttpPut("org/{insigniaManageOrgId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> PutOrganization([FromForm] InsigniaManageOrganizationUpdateRequest req, Guid insigniaManageOrgId)
|
public async Task<ActionResult<ResponseObject>> PutOrganization([FromBody] InsigniaManageOrganizationUpdateRequest req, Guid insigniaManageOrgId)
|
||||||
{
|
{
|
||||||
var uppdated = await _context.InsigniaManageOrganiations.AsQueryable()
|
var uppdated = await _context.InsigniaManageOrganiations.AsQueryable()
|
||||||
.Include(x => x.OrganizationOrganization)
|
.Include(x => x.OrganizationOrganization)
|
||||||
|
|
@ -401,11 +402,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPost("borrow")]
|
[HttpPost("borrow")]
|
||||||
public async Task<ActionResult<ResponseObject>> PostBorrowInsignia([FromForm] InsigniaBorrowRequest req)
|
public async Task<ActionResult<ResponseObject>> PostBorrowInsignia([FromBody] InsigniaBorrowRequest req)
|
||||||
{
|
{
|
||||||
var organizationOrganization = await _context.OrganizationOrganizations.AsQueryable()
|
var organization = await _context.Organizations.AsQueryable()
|
||||||
|
.Include(x => x.OrganizationOrganization)
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.BorrowOrganizationId);
|
.FirstOrDefaultAsync(x => x.Id == req.BorrowOrganizationId);
|
||||||
if (organizationOrganization == null)
|
if (organization == null)
|
||||||
return Error(GlobalMessages.OrganizationNotFound);
|
return Error(GlobalMessages.OrganizationNotFound);
|
||||||
|
|
||||||
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.AsQueryable()
|
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.AsQueryable()
|
||||||
|
|
@ -421,7 +423,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
var insigniaManageOrganiation = await _context.InsigniaManageOrganiations.AsQueryable()
|
var insigniaManageOrganiation = await _context.InsigniaManageOrganiations.AsQueryable()
|
||||||
.Include(x => x.InsigniaManageProfiles)
|
.Include(x => x.InsigniaManageProfiles)
|
||||||
.FirstOrDefaultAsync(x => x.OrganizationOrganization == organizationOrganization && x.InsigniaManage == insigniaManage);
|
.FirstOrDefaultAsync(x => x.OrganizationOrganization == organization.OrganizationOrganization && x.InsigniaManage == insigniaManage);
|
||||||
if (insigniaManageOrganiation == null)
|
if (insigniaManageOrganiation == null)
|
||||||
return Error(GlobalMessages.InsigniaManageOrgNotFound);
|
return Error(GlobalMessages.InsigniaManageOrgNotFound);
|
||||||
|
|
||||||
|
|
@ -438,7 +440,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
{
|
{
|
||||||
Status = false,
|
Status = false,
|
||||||
InsigniaManageOrganiation = insigniaManageOrganiation,
|
InsigniaManageOrganiation = insigniaManageOrganiation,
|
||||||
BorrowOrganization = organizationOrganization,
|
BorrowOrganization = organization.OrganizationOrganization,
|
||||||
BorrowDate = req.BorrowDate,
|
BorrowDate = req.BorrowDate,
|
||||||
InsigniaNoteProfile = insigniaNoteProfile,
|
InsigniaNoteProfile = insigniaNoteProfile,
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
|
|
@ -464,11 +466,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPut("return/{insigniaManageProfileId:length(36)}")]
|
[HttpPut("return/{insigniaManageProfileId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> PutReturnInsignia([FromForm] InsigniaReturnRequest req, Guid insigniaManageProfileId)
|
public async Task<ActionResult<ResponseObject>> PutReturnInsignia([FromBody] InsigniaReturnRequest req, Guid insigniaManageProfileId)
|
||||||
{
|
{
|
||||||
var organizationOrganization = await _context.OrganizationOrganizations.AsQueryable()
|
var organization = await _context.Organizations.AsQueryable()
|
||||||
|
.Include(x => x.OrganizationOrganization)
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.ReturnOrganizationId);
|
.FirstOrDefaultAsync(x => x.Id == req.ReturnOrganizationId);
|
||||||
if (organizationOrganization == null)
|
if (organization == null)
|
||||||
return Error(GlobalMessages.OrganizationNotFound);
|
return Error(GlobalMessages.OrganizationNotFound);
|
||||||
|
|
||||||
var uppdated = await _context.InsigniaManageProfiles.AsQueryable()
|
var uppdated = await _context.InsigniaManageProfiles.AsQueryable()
|
||||||
|
|
@ -478,7 +481,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
uppdated.Status = true;
|
uppdated.Status = true;
|
||||||
uppdated.ReturnDate = req.ReturnDate;
|
uppdated.ReturnDate = req.ReturnDate;
|
||||||
uppdated.ReturnOrganization = organizationOrganization;
|
uppdated.ReturnOrganization = organization.OrganizationOrganization;
|
||||||
uppdated.ReturnReason = req.ReturnReason;
|
uppdated.ReturnReason = req.ReturnReason;
|
||||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
uppdated.LastUpdateUserId = UserId ?? "";
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue