Example #1
0
        public static EmployeeRoleRL CreateEmployeeRoleRL(Guid fkEmployeeID, Guid fkRoleID)
        {
            EmployeeRoleRL emRole = null;

            if (Guid.Empty != fkRoleID)
            {
                emRole = new EmployeeRoleRL();
                emRole.FKEmployeeID = fkEmployeeID;
                emRole.FKRoleID     = fkRoleID;
                emRole.IsDeleted    = false;
                emRole.InitChildren();
            }

            return(emRole);
        }
Example #2
0
        public void SetPrivilege(bool value, RoleRank role)
        {
            bool           isExistRole = false;
            EmployeeRoleRL emRole      = null;

            int index = 0;

            foreach (EmployeeRoleRL item in employeeRoleList)
            {
                if ((role == RoleRank.Admin && item.EmployeeRole.Name.Equals(RoleRank.Admin.ToString())) ||
                    (role == RoleRank.Manager && item.EmployeeRole.Name.Equals(RoleRank.Manager.ToString())))
                {
                    isExistRole = true;
                    emRole      = item;
                    break;
                }

                index++;
            }

            if (value)
            {
                if (!isExistRole)
                {
                    Role roleObject = Role.GetRoleByName(role.ToString());
                    emRole = EmployeeRoleRL.CreateEmployeeRoleRL(PKEmployeeID, roleObject.PKRoleID);
                    employeeRoleList.Add(emRole);
                }
            }
            else
            {
                if (isExistRole)
                {
                    //employeeRoleList.RemoveAt(index);
                    emRole.IsDeleted = true;
                }
            }
        }