private async Task <bool> HasAccessForEmployeeContext(User user, ProtectedContextMember <Permission> privilege, Employee context) { switch (privilege.PrivilegeName) { case "Employee_Action_View": var userPermissions = await GetUserPermissions(user); var requiredPermission = new Permission { Value = context.Location }; return(userPermissions.Any((permission) => permission.Equals(requiredPermission))); default: return(false); } }
protected virtual Task <bool> HasAccessForContext <TContext>(TUser user, ProtectedContextMember <TPermission> privilege, TContext context) { throw new NotImplementedException(); }
protected override async Task <bool> HasAccessForContext <TContext>(User user, ProtectedContextMember <Permission> privilege, TContext context) { if (context is Employee employeeContext) { return(await HasAccessForEmployeeContext(user, privilege, employeeContext)); } return(false); }