private async Task performSearch(string searchTerms, bool isDeepLink = false) { IEnumerable <IContentItem> children = null; try { if (isDeepLink) { children = await ContentClient.DeepLink(selectedChannel.ID, searchTerms); } else { children = await ContentClient.Search(selectedChannel.ID, searchTerms); } } catch (SessionExpiredException) { await getItemChildren(selectedChannel, true); if (isDeepLink) { children = await ContentClient.DeepLink(selectedChannel.ID, searchTerms); } else { children = await ContentClient.Search(selectedChannel.ID, searchTerms); } } var name = searchTerms; if (isDeepLink) { name = "Videos"; } ContentItemEx searchResults = new ContentItemEx { Type = ContentType.Folder, ID = searchTerms, Parent = selectedChannel, Name = name, IsFromSearch = !isDeepLink, IsDeepLink = isDeepLink }; if (children != null) { searchResults.Children = new ObservableCollection <IContentItem>(children); } selectedItem = searchResults; updateBreadcrumbs(); SelectedFolder = selectedItem; OnPropertyChanged("SelectedItem"); }
public async Task <string> GetNewItemID(List <IContentItem> parents, string name) { if ((parents == null) || !parents.Any() || string.IsNullOrEmpty(name)) { return(null); } if ((Root == null) || (Root.Children == null)) { return(null); } var channel = Root.Children.FirstOrDefault(c => c.Name == parents[0].Name); if (channel == null) { return(null); } string currentID = channel.ID; while (parents.Count > 0) { var currentParent = parents[0]; parents.RemoveAt(0); string title = name; if (parents.Count > 0) { title = parents[0].Name; } IEnumerable <ContentItemEx> items = null; try { if ((currentID == channel.ID) && (channel is ChannelEx) && ((channel as ChannelEx).LoginInfo != null) && (channel as ChannelEx).LoginInfo.HasCredentials) { items = await ContentClient.LoginAndGetChildren(currentID, (channel as ChannelEx).LoginInfo); } else { if (currentParent.IsFromSearch) { items = await ContentClient.Search(channel.ID, currentID); } else if (currentParent.IsDeepLink) { items = await ContentClient.DeepLink(channel.ID, currentID); } else { items = await ContentClient.GetChildren(currentID); } } } catch { } if ((items == null) || !items.Any()) { return(null); } if (parents.Count == 0) { var item = items.FirstOrDefault(i => i.Name == name); if (item != null) { return(item.ID); } } else { var item = items.FirstOrDefault(i => i.Name == title); if (item != null) { currentID = item.ID; } else if (parents[0].IsFromSearch || parents[0].IsDeepLink) { currentID = parents[0].ID; } else { return(null); } } } return(null); }