TraktPlugin.TraktLists.GetUserListSelections C# (CSharp) Méthode

GetUserListSelections() public static méthode

Get the ids for each list selected by a user in the Multi-Select dialog
public static GetUserListSelections ( List lists ) : List
lists List
Résultat List
        public static List<int> GetUserListSelections(List<TraktListDetail> lists)
        {
            if (lists.Count == 0)
            {
                if (!GUIUtils.ShowYesNoDialog(Translation.Lists, Translation.NoListsFound, true))
                {
                    // nothing to do, return
                    return null;
                }
                var list = new TraktListDetail();
                if (TraktLists.GetListDetailsFromUser(ref list))
                {
                    TraktLogger.Info("Creating new list for user online. Privacy = '{0}', Name = '{1}'", list.Privacy, list.Name);
                    var response = TraktAPI.TraktAPI.CreateCustomList(list);
                    if (response != null)
                    {
                        ClearListCache(TraktSettings.Username);
                        return new List<int> { (int)response.Ids.Trakt };
                    }
                }
                  return null;
            }

            List<MultiSelectionItem> selectedItems = GUIUtils.ShowMultiSelectionDialog(Translation.SelectLists, GetMultiSelectItems(lists));
            if (selectedItems == null) return null;

            var listIds = new List<int>();
            foreach (var item in selectedItems.Where(l => l.Selected == true))
            {
                listIds.Add(int.Parse(item.ItemID));
            }
            return listIds;
        }

Usage Example

Exemple #1
0
        public static void AddRemoveEpisodeInUserList(string username, string title, string year, string season, string episode, string tvdbid, bool remove)
        {
            if (!GUICommon.CheckLogin(false))
            {
                return;
            }

            GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() =>
            {
                return(TraktLists.GetListsForUser(username));
            },
                                                                      delegate(bool success, object result)
            {
                if (success)
                {
                    IEnumerable <TraktUserList> customlists = result as IEnumerable <TraktUserList>;

                    // get slug of lists selected
                    List <string> slugs = TraktLists.GetUserListSelections(customlists.ToList());
                    if (slugs == null || slugs.Count == 0)
                    {
                        return;
                    }

                    TraktListItem item = new TraktListItem
                    {
                        Type    = TraktItemType.episode.ToString(),
                        Title   = title,
                        Year    = Convert.ToInt32(year),
                        Season  = Convert.ToInt32(season),
                        Episode = Convert.ToInt32(episode),
                        TvdbId  = tvdbid
                    };

                    AddRemoveItemInList(slugs, item, remove);
                }
            }, Translation.GettingLists, true);
        }