Jump to content

Proper way to get the containing library of a BaseItem


rechigo

Recommended Posts

rechigo

I've tried a couple different ways, but all of them result in an Id that is not equal to that of the containing library.

 

BaseItem.Parent

BaseItem.GetTopParent()

 

All of them give me the correct NAME of the library (movies), but the ID does not correlate to that of the Movies library returned in UserViewManager.GetUserViews

 

TLDR: HOW can I get the the ID of the Library that the BaseItem is part of 

Edited by rechigo
Link to comment
Share on other sites

pünktchen

What Id of the BaseItem do you look at? There are many of them and it depends on what to do next with the Id, but i guess you want to use InternalId.

Link to comment
Share on other sites

rechigo

What Id of the BaseItem do you look at? There are many of them and it depends on what to do next with the Id, but i guess you want to use InternalId.

 

I'm looking at the Id property (GUID)

 

I just do not know how to get the Library ID (guid) that the base item is part of

 

Okay, I ended up just doing it like this

_userViewManager.GetUserViews(
    new UserViewQuery {
        UserId = _userManager.GetInternalId(Guid.Parse(UserId))
    }
).ToList().ForEach(folder => {
    if(folder.GetItemIdList(new InternalItemsQuery {}).Contains(item.InternalId)) {
        // do whatever now that we know it is in a library the user can access
    }
});
Edited by rechigo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...