/// <summary> /// 權限判斷。 /// </summary> /// <param name="roleDatas">多筆角色資料。</param> /// <param name="canGetter">取得 allow 欄位的方法。</param> /// <param name="denyPriv">拒絕權限資料。</param> /// <param name="denyGetter">取得 deny 欄位的方法。</param> /// <returns> /// 如果有權限則回傳 true;否則回傳 false。 /// </returns> private bool Judge(IEnumerable<Role> roleDatas, Func<Role, bool?> canGetter, DenyPriv denyPriv, Func<DenyPriv, bool> denyGetter) { // is denied ? if (denyPriv != null && denyGetter(denyPriv)) { return false; } // is granted ? if (roleDatas != null && roleDatas.Any(r => canGetter(r) == true)) { return true; } // default is false. return false; }
private DenyPriv CreateDenyData(bool deny) { var denyData = new DenyPriv { Select = deny, Insert = deny, Update = deny, Delete = deny, Particular = deny, }; return denyData; }