api จัดการคำขอเครื่องราช
This commit is contained in:
parent
4215af4a0b
commit
f386a5fea6
8 changed files with 409 additions and 233 deletions
|
|
@ -65,6 +65,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = p.Id,
|
||||
period_amount = p.Amount,
|
||||
period_name = p.Name,
|
||||
period_round = p.Round,
|
||||
period_start = p.StartDate,
|
||||
period_end = p.EndDate,
|
||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
||||
|
|
@ -81,6 +82,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = insigniaPeriod.period_id,
|
||||
period_amount = insigniaPeriod.period_amount,
|
||||
period_name = insigniaPeriod.period_name,
|
||||
period_round = insigniaPeriod.period_round,
|
||||
period_start = insigniaPeriod.period_start,
|
||||
period_end = insigniaPeriod.period_end,
|
||||
period_status = insigniaPeriod.period_status,
|
||||
|
|
@ -113,6 +115,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = p.Id,
|
||||
period_amount = p.Amount,
|
||||
period_name = p.Name,
|
||||
period_round = p.Round,
|
||||
period_start = p.StartDate,
|
||||
period_end = p.EndDate,
|
||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
||||
|
|
@ -129,6 +132,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = data.period_id,
|
||||
period_amount = data.period_amount,
|
||||
period_name = data.period_name,
|
||||
period_round = data.period_round,
|
||||
period_start = data.period_start,
|
||||
period_end = data.period_end,
|
||||
period_status = data.period_status,
|
||||
|
|
@ -144,6 +148,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
/// สร้างรอบเครื่องราช
|
||||
/// </summary>
|
||||
/// <param name="type">ประเภทเครื่องราช(insignia=เครื่องราช,coin=เหรียญ)</param>
|
||||
/// <param name="req.Round">รอบที่</param>
|
||||
/// <param name="req.Name">ชื่อรอบ</param>
|
||||
/// <param name="req.Year">ปีที่เสนอ</param>
|
||||
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
||||
|
|
@ -158,13 +163,20 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPost("{type}")]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req, string type)
|
||||
{
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Where(x => x.Round == req.Round && x.Year == req.Year)
|
||||
.FirstOrDefaultAsync();
|
||||
if (insigniaPeriod != null)
|
||||
return Error(GlobalMessages.InsigniaDupicate);
|
||||
|
||||
var period = new InsigniaPeriod
|
||||
{
|
||||
Name = Request.Form.ContainsKey("Name") ? Request.Form["Name"] : "",
|
||||
Year = Request.Form.ContainsKey("Year") ? Int32.Parse(Request.Form["Year"]) : DateTime.Now.Year,
|
||||
StartDate = Request.Form.ContainsKey("StartDate") ? DateTime.Parse(Request.Form["StartDate"]) : DateTime.Now,
|
||||
EndDate = Request.Form.ContainsKey("EndDate") ? DateTime.Parse(Request.Form["EndDate"]) : DateTime.Now,
|
||||
Amount = Request.Form.ContainsKey("Amount") ? Request.Form["Amount"] : "",
|
||||
Round = req.Round,
|
||||
Name = req.Name,
|
||||
Year = req.Year,
|
||||
StartDate = req.StartDate,
|
||||
EndDate = req.EndDate,
|
||||
Amount = req.Amount,
|
||||
Type = type.Trim().ToUpper(),
|
||||
IsActive = true,
|
||||
CreatedUserId = FullName ?? "",
|
||||
|
|
@ -221,6 +233,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
/// แก้ไขรอบเครื่องราช
|
||||
/// </summary>
|
||||
/// <param name="id">Id เครื่องราช</param>
|
||||
/// <param name="req.Round">รอบที่</param>
|
||||
/// <param name="req.Name">ชื่อรอบ</param>
|
||||
/// <param name="req.Year">ปีที่เสนอ</param>
|
||||
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
||||
|
|
@ -238,6 +251,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
if (req == null)
|
||||
return BadRequest();
|
||||
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Where(x => x.Round == req.Round && x.Year == req.Year && x.Id != id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (insigniaPeriod != null)
|
||||
return Error(GlobalMessages.InsigniaDupicate);
|
||||
|
||||
var uppdated = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Include(x => x.ReliefDoc)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
|
@ -245,11 +264,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
if (uppdated == null)
|
||||
return NotFound();
|
||||
|
||||
uppdated.Name = Request.Form.ContainsKey("Name") ? Request.Form["Name"] : "";
|
||||
uppdated.Year = Request.Form.ContainsKey("Year") ? Int32.Parse(Request.Form["Year"]) : DateTime.Now.Year;
|
||||
uppdated.StartDate = Request.Form.ContainsKey("StartDate") ? DateTime.Parse(Request.Form["StartDate"]) : DateTime.Now;
|
||||
uppdated.EndDate = Request.Form.ContainsKey("EndDate") ? DateTime.Parse(Request.Form["EndDate"]) : DateTime.Now;
|
||||
uppdated.Amount = Request.Form.ContainsKey("Amount") ? Request.Form["Amount"] : "";
|
||||
uppdated.Round = req.Round;
|
||||
uppdated.Name = req.Name;
|
||||
uppdated.Year = req.Year;
|
||||
uppdated.StartDate = req.StartDate;
|
||||
uppdated.EndDate = req.EndDate;
|
||||
uppdated.Amount = req.Amount;
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue