เพิ่มรับคืนเครื่องราช

This commit is contained in:
Kittapath 2023-09-26 17:51:18 +07:00
parent 59f782e8cf
commit 1619a502d4
22 changed files with 33518 additions and 41 deletions

View file

@ -432,28 +432,47 @@ namespace BMA.EHR.OrganizationEmployee.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == req.OrganizationEmployeeId);
if (organizationEmployee == null)
return Error(GlobalMessages.OrganizationEmployeeNotFound, 404);
var organizationEmployeeProfile = await _context.OrganizationEmployees
.Include(x => x.Profile)
// var organizationEmployeeProfile = await _context.OrganizationEmployees
// .Include(x => x.Profile)
// .FirstOrDefaultAsync(x => x.Profile == profile);
// if (organizationEmployeeProfile != null)
// organizationEmployeeProfile.Profile = null;
var organizationEmployeeProfileDup = await _context.OrganizationEmployeeProfiles
.FirstOrDefaultAsync(x => x.Profile != profile && x.OrgEmployee == organizationEmployee);
if (organizationEmployeeProfileDup != null)
return Error(GlobalMessages.OrganizationEmployeeDupicate);
var organizationEmployeeProfile = await _context.OrganizationEmployeeProfiles
.FirstOrDefaultAsync(x => x.Profile == profile);
if (organizationEmployeeProfile != null)
organizationEmployeeProfile.Profile = null;
var data = new OrganizationEmployeeProfile
if (organizationEmployeeProfile == null)
{
OrgEmployee = organizationEmployee,
Profile = profile,
Status = "PENDING",
CreatedUserId = UserId ?? "System Administrator",
CreatedFullName = FullName ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.OrganizationEmployeeProfiles.AddAsync(data);
var data = new OrganizationEmployeeProfile
{
OrgEmployee = organizationEmployee,
Profile = profile,
Status = "PENDING",
CreatedUserId = UserId ?? "System Administrator",
CreatedFullName = FullName ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.OrganizationEmployeeProfiles.AddAsync(data);
}
else
{
organizationEmployeeProfile.OrgEmployee = organizationEmployee;
organizationEmployeeProfile.Status = "PENDING";
organizationEmployeeProfile.CreatedUserId = UserId ?? "System Administrator";
organizationEmployeeProfile.CreatedFullName = FullName ?? "";
organizationEmployeeProfile.CreatedAt = DateTime.Now;
organizationEmployeeProfile.LastUpdateFullName = FullName ?? "System Administrator";
organizationEmployeeProfile.LastUpdateUserId = UserId ?? "";
organizationEmployeeProfile.LastUpdatedAt = DateTime.Now;
}
// organizationEmployee.Profile = profile;
// organizationEmployee.IsPublic = false;
_context.SaveChanges();
await _context.SaveChangesAsync();
return Success();
}