เพิ่มรับคืนเครื่องราช
This commit is contained in:
parent
59f782e8cf
commit
1619a502d4
22 changed files with 33518 additions and 41 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue