Role Permission
This commit is contained in:
parent
83b5935846
commit
8b452c2bbd
|
|
@ -329,16 +329,12 @@ namespace HRM.DA
|
|||
public int Save(Role oRole)
|
||||
{
|
||||
TransactionContext tc = null;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
tc = TransactionContext.Begin(true);
|
||||
|
||||
// Audit of the permission rows, by PermissionCode, read before they are deleted and
|
||||
// re-inserted below, so each kept menu keeps who/when it was created and approved.
|
||||
Dictionary<string, Role.RolePermission> existingPermissions = new Dictionary<string, Role.RolePermission>();
|
||||
|
||||
if (oRole.IsNew)
|
||||
{
|
||||
int id = tc.GenerateID("Role", "RoleID");
|
||||
|
|
@ -361,11 +357,10 @@ namespace HRM.DA
|
|||
RoleDA.Update(tc, oRole);
|
||||
#region Delete Children
|
||||
RoleDA.Delete(tc, "RolePermission", "RoleID", oRole.ID);
|
||||
// RoleDA.Delete(tc, "Role.RoleActionPermission", "RoleID", oRole.ID);
|
||||
// RoleDA.Delete(tc, "RoleDesignation", "RoleID", oRole.ID);
|
||||
//RoleDA.Delete(tc, "Role.RoleActionPermission", "RoleID", oRole.ID);
|
||||
//RoleDA.Delete(tc, "RoleDesignation", "RoleID", oRole.ID);
|
||||
#endregion
|
||||
}
|
||||
|
||||
if (oRole.RolePermissions != null & oRole.RolePermissions.Count > 0)
|
||||
{
|
||||
int maxID = oRole.RolePermissions.Max(x => x.ID);
|
||||
|
|
@ -389,15 +384,12 @@ namespace HRM.DA
|
|||
// Whoever made this change: the editor, or the creator for a new role. On approval
|
||||
// the controller keeps the maker in ModifiedBy, so this is still the maker.
|
||||
int makerID = (oRole.ModifiedBy ?? 0) > 0 ? oRole.ModifiedBy.Value : oRole.CreatedBy;
|
||||
|
||||
foreach (Role.RolePermission rolePermission in oRole.RolePermissions)
|
||||
{
|
||||
rolePermission.RoleID = oRole.ID;
|
||||
|
||||
Role.RolePermission existingPermission = null;
|
||||
if (rolePermission.PermissionCode != null)
|
||||
existingPermissions.TryGetValue(rolePermission.PermissionCode, out existingPermission);
|
||||
|
||||
if (existingPermission != null)
|
||||
{
|
||||
// Menu the role already had: keep its original audit.
|
||||
|
|
|
|||
|
|
@ -1307,17 +1307,12 @@ namespace HRM.UI.Controllers
|
|||
}
|
||||
role.RoleStatus = EnumAuthStatus.EditedNotYetApprove;
|
||||
}
|
||||
|
||||
// The browser sends createdBy 0 on edit/approve; use the real creator (RoleDA.Update
|
||||
// does not write it, it is only used for the permission rows' audit).
|
||||
role.CreatedBy = existingRole.CreatedBy;
|
||||
role.CreatedDate = existingRole.CreatedDate;
|
||||
role.ApproveDate = null;
|
||||
role.ApproveBy = null;
|
||||
if (role.RoleStatus == EnumAuthStatus.Approved)
|
||||
{
|
||||
// Approval keeps the maker (who made the change) on the role; the approver is
|
||||
// recorded separately in ApproveBy / ApproveDate below.
|
||||
role.ModifiedBy = existingRole.ModifiedBy;
|
||||
role.ModifiedDate = existingRole.ModifiedDate;
|
||||
}
|
||||
|
|
@ -1327,13 +1322,11 @@ namespace HRM.UI.Controllers
|
|||
role.ModifiedDate = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
if (role.RoleStatus == EnumAuthStatus.Approved)
|
||||
{
|
||||
role.ApproveDate = DateTime.Today;
|
||||
role.ApproveBy = currentUser.UserID;
|
||||
}
|
||||
|
||||
id = this._roleService.Save(role);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user