แก้api เกษียญอื่นๆให้เหมือนรับโอน
This commit is contained in:
parent
243700bd53
commit
1b70ad6816
22 changed files with 15373 additions and 389 deletions
|
|
@ -47,7 +47,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// list รายการอื่นๆของ Admin
|
||||
/// list รายการอื่นๆ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -63,33 +63,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||
p.CreatedAt,
|
||||
p.Organization,
|
||||
p.Reason,
|
||||
p.CitizenId,
|
||||
Prefix = p.Prefix == null ? null : p.Prefix.Name,
|
||||
p.Firstname,
|
||||
p.Lastname,
|
||||
p.DateOfBirth,
|
||||
Gender = p.Gender == null ? null : p.Gender.Name,
|
||||
p.Status,
|
||||
p.Date,
|
||||
p.Amount,
|
||||
p.RecruitDate,
|
||||
PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
|
||||
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
|
||||
PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
|
||||
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
||||
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
||||
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
||||
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
p.IsActive,
|
||||
p.PositionDate,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
salary = p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (RetirementAdmin == true)
|
||||
retirementOthers.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||
retirementOthers.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||
|
||||
return Success(retirementOthers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get รายละเอียดอื่นๆเจ้าหน้าที่
|
||||
/// get รายละเอียดอื่นๆ
|
||||
/// </summary>
|
||||
/// <param name="id">Id อื่นๆ</param>
|
||||
/// <returns></returns>
|
||||
|
|
@ -98,39 +115,100 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
|
||||
{
|
||||
var data = await _context.RetirementOthers.AsQueryable()
|
||||
.Where(x => x.Id == id)
|
||||
.Where(x => x.Profile != null)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
ProfileId = p.Profile.Id,
|
||||
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||
p.Reason,
|
||||
p.CitizenId,
|
||||
Prefix = p.Prefix == null ? null : p.Prefix.Name,
|
||||
PrefixId = p.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Prefix.Id,
|
||||
p.Firstname,
|
||||
p.Lastname,
|
||||
p.DateOfBirth,
|
||||
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
|
||||
p.Nationality,
|
||||
p.Race,
|
||||
Religion = p.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Religion.Id,
|
||||
BloodGroup = p.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.BloodGroup.Id,
|
||||
Relationship = p.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Relationship.Id,
|
||||
p.TelephoneNumber,
|
||||
p.Status,
|
||||
p.Organization,
|
||||
p.Date,
|
||||
salary = p.AmountOld,
|
||||
p.Amount,
|
||||
p.RecruitDate,
|
||||
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||
p.CreatedAt,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
salary = p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.PositionDate,
|
||||
RetirementOtherDocs = p.RetirementOtherDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
return Success(data);
|
||||
var retirementOtherDocs = new List<dynamic>();
|
||||
foreach (var doc in data.RetirementOtherDocs)
|
||||
{
|
||||
var _doc = new
|
||||
{
|
||||
doc.FileName,
|
||||
PathName = await _documentService.ImagesPath(doc.Id)
|
||||
};
|
||||
retirementOtherDocs.Add(_doc);
|
||||
}
|
||||
var _data = new
|
||||
{
|
||||
data.Id,
|
||||
data.CitizenId,
|
||||
data.Prefix,
|
||||
data.PrefixId,
|
||||
data.Firstname,
|
||||
data.Lastname,
|
||||
data.DateOfBirth,
|
||||
data.Gender,
|
||||
data.Nationality,
|
||||
data.Race,
|
||||
data.Religion,
|
||||
data.BloodGroup,
|
||||
data.Relationship,
|
||||
data.TelephoneNumber,
|
||||
data.Status,
|
||||
data.Amount,
|
||||
data.RecruitDate,
|
||||
data.PosNoId,
|
||||
data.PositionId,
|
||||
data.PositionPathSideId,
|
||||
data.PositionTypeId,
|
||||
data.PositionLineId,
|
||||
data.PositionLevelId,
|
||||
data.OrganizationPositionId,
|
||||
data.CreatedAt,
|
||||
data.Reason,
|
||||
data.EducationOld,
|
||||
data.salary,
|
||||
data.PositionTypeOld,
|
||||
data.PositionLevelOld,
|
||||
data.PositionNumberOld,
|
||||
data.OrganizationPositionOld,
|
||||
data.PositionDate,
|
||||
Docs = retirementOtherDocs,
|
||||
};
|
||||
|
||||
return Success(_data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -149,17 +227,29 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Educations)
|
||||
.Include(x => x.Position)
|
||||
.Include(x => x.Gender)
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var retirementOther = new RetirementOther
|
||||
{
|
||||
Profile = profile,
|
||||
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||
// Date = req.Date,
|
||||
CitizenId = profile.CitizenId,
|
||||
Prefix = profile.Prefix,
|
||||
Firstname = profile.FirstName,
|
||||
Lastname = profile.LastName,
|
||||
DateOfBirth = profile.BirthDate,
|
||||
Gender = profile.Gender,
|
||||
Nationality = profile.Nationality,
|
||||
Race = profile.Race,
|
||||
Religion = await _context.Religions.FindAsync(profile.ReligionId),
|
||||
BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
|
||||
Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
|
||||
TelephoneNumber = profile.TelephoneNumber,
|
||||
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
|
||||
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||
|
|
@ -175,6 +265,114 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
};
|
||||
await _context.RetirementOthers.AddAsync(retirementOther);
|
||||
await _context.SaveChangesAsync();
|
||||
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 retirementOtherDoc = new RetirementOtherDoc
|
||||
{
|
||||
RetirementOther = retirementOther,
|
||||
Document = _doc,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.RetirementOtherDocs.AddAsync(retirementOtherDoc);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เลือกหน่วยงาน
|
||||
/// </summary>
|
||||
/// <param name="id">Id อื่นๆ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("position/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePositionRetirementOther([FromBody] PersonSelectPositionOtherRequest req, Guid id)
|
||||
{
|
||||
var uppdated = await _context.RetirementOthers
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.RetirementOtherNotFound, 404);
|
||||
if (req.PosNoId != null)
|
||||
{
|
||||
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
|
||||
if (save_posNo == null)
|
||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||
uppdated.PositionNumber = save_posNo;
|
||||
|
||||
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
|
||||
if (save_orgPosition == null)
|
||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||
uppdated.OrganizationPosition = save_orgPosition;
|
||||
}
|
||||
|
||||
if (req.PositionId != null)
|
||||
{
|
||||
var save = await _context.PositionPaths.FindAsync(req.PositionId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionPathNotFound, 404);
|
||||
uppdated.PositionPath = save;
|
||||
}
|
||||
|
||||
if (req.PositionLevelId != null)
|
||||
{
|
||||
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionLevelNotFound, 404);
|
||||
uppdated.PositionLevel = save;
|
||||
}
|
||||
|
||||
if (req.PositionLineId != null)
|
||||
{
|
||||
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionLineNotFound, 404);
|
||||
uppdated.PositionLine = save;
|
||||
}
|
||||
|
||||
if (req.PositionPathSideId != null)
|
||||
{
|
||||
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionPathSideNotFound, 404);
|
||||
uppdated.PositionPathSide = save;
|
||||
}
|
||||
|
||||
if (req.PositionTypeId != null)
|
||||
{
|
||||
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionTypeNotFound, 404);
|
||||
uppdated.PositionType = save;
|
||||
}
|
||||
|
||||
uppdated.Amount = req.Amount;
|
||||
uppdated.RecruitDate = req.RecruitDate;
|
||||
uppdated.Status = "PENDING";
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -195,40 +393,61 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
if (uppdated == null)
|
||||
return Error(GlobalMessages.RetirementOtherNotFound, 404);
|
||||
|
||||
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||
uppdated.AmountOld = req.AmountOld;
|
||||
uppdated.Organization = req.Organization;
|
||||
|
||||
if (req.PrefixId != null)
|
||||
{
|
||||
var save = await _context.Prefixes.FindAsync(req.PrefixId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||
uppdated.Prefix = save;
|
||||
}
|
||||
|
||||
if (req.RelationshipId != null)
|
||||
{
|
||||
var save = await _context.Relationships.FindAsync(req.RelationshipId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.RelationshipNotFound, 404);
|
||||
uppdated.Relationship = save;
|
||||
}
|
||||
|
||||
if (req.ReligionId != null)
|
||||
{
|
||||
var save = await _context.Religions.FindAsync(req.ReligionId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.ReligionNotFound, 404);
|
||||
uppdated.Religion = save;
|
||||
}
|
||||
|
||||
if (req.BloodGroupId != null)
|
||||
{
|
||||
var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.BloodGroupNotFound, 404);
|
||||
uppdated.BloodGroup = save;
|
||||
}
|
||||
|
||||
if (req.GenderId != null)
|
||||
{
|
||||
var save = await _context.Genders.FindAsync(req.GenderId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.GenderNotFound, 404);
|
||||
uppdated.Gender = save;
|
||||
}
|
||||
uppdated.CitizenId = req.CitizenId;
|
||||
uppdated.Firstname = req.Firstname;
|
||||
uppdated.Lastname = req.Lastname;
|
||||
uppdated.DateOfBirth = req.DateOfBirth;
|
||||
uppdated.Nationality = req.Nationality;
|
||||
uppdated.Race = req.Race;
|
||||
uppdated.TelephoneNumber = req.TelephoneNumber;
|
||||
uppdated.EducationOld = req.EducationOld;
|
||||
uppdated.Reason = req.Reason;
|
||||
uppdated.Date = req.Date;
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อนุมัติอื่นๆ
|
||||
/// </summary>
|
||||
/// <param name="id">Id อื่นๆ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("confirm/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||
{
|
||||
var uppdated = await _context.RetirementOthers
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.RetirementOtherNotFound, 404);
|
||||
|
||||
uppdated.Status = "APPROVE";
|
||||
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||
uppdated.AmountOld = req.AmountOld;
|
||||
uppdated.PositionDate = req.PositionDate;
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
|
|
@ -250,10 +469,25 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||
{
|
||||
var deleted = await _context.RetirementOthers.AsQueryable()
|
||||
.Include(x => x.RetirementOtherDocs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return NotFound();
|
||||
var retirementOtherDocs = new List<dynamic>();
|
||||
foreach (var doc in deleted.RetirementOtherDocs)
|
||||
{
|
||||
if (doc.Document != null)
|
||||
retirementOtherDocs.Add(doc.Document.Id);
|
||||
}
|
||||
_context.RetirementOtherDocs.RemoveRange(deleted.RetirementOtherDocs);
|
||||
await _context.SaveChangesAsync();
|
||||
_context.RetirementOthers.Remove(deleted);
|
||||
foreach (var doc in retirementOtherDocs)
|
||||
{
|
||||
if (doc != null)
|
||||
await _documentService.DeleteFileAsync(doc);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class PersonSelectPositionReceiveRequest
|
||||
public class PersonSelectPositionOtherRequest
|
||||
{
|
||||
public DateTime? RecruitDate { get; set; }
|
||||
public Guid? PosNoId { get; set; }
|
||||
|
|
@ -12,5 +12,6 @@ namespace BMA.EHR.Retirement.Service.Requests
|
|||
public Guid? PositionLineId { get; set; }
|
||||
public Guid? PositionPathSideId { get; set; }
|
||||
public Guid? PositionTypeId { get; set; }
|
||||
public double? Amount { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -5,13 +5,25 @@ namespace BMA.EHR.Retirement.Service.Requests
|
|||
{
|
||||
public class RetirementOtherEditRequest
|
||||
{
|
||||
public string Organization { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public string CitizenId { get; set; }
|
||||
public Guid PrefixId { get; set; }
|
||||
public string Firstname { get; set; }
|
||||
public string Lastname { get; set; }
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
public Guid? GenderId { get; set; }
|
||||
public string? Nationality { get; set; }
|
||||
public string? Race { get; set; }
|
||||
public Guid? ReligionId { get; set; }
|
||||
public Guid? BloodGroupId { get; set; }
|
||||
public Guid? RelationshipId { get; set; }
|
||||
public string? TelephoneNumber { get; set; }
|
||||
public string? Reason { get; set; }
|
||||
public string? EducationOld { get; set; }
|
||||
public string? OrganizationPositionOld { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
public string? PositionTypeOld { get; set; }
|
||||
public string? PositionLevelOld { get; set; }
|
||||
public string? PositionNumberOld { get; set; }
|
||||
public double? AmountOld { get; set; }
|
||||
public DateTime? PositionDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue