TraktPlugin.TraktHelper.AddRemoveItemInList C# (CSharp) Méthode

AddRemoveItemInList() static private méthode

static private AddRemoveItemInList ( List listIds, TraktSyncAll items, bool remove ) : void
listIds List
items TraktPlugin.TraktAPI.DataStructures.TraktSyncAll
remove bool
Résultat void
        internal static void AddRemoveItemInList(List<int> listIds, TraktSyncAll items, bool remove)
        {
            var listThread = new Thread((o) =>
            {
                foreach (int listId in listIds)
                {
                    TraktSyncResponse response = null;
                    if (!remove)
                    {
                        response = TraktAPI.TraktAPI.AddItemsToList("me", listId.ToString(), items);
                    }
                    else
                    {
                        response = TraktAPI.TraktAPI.RemoveItemsFromList("me", listId.ToString(), items);
                    }

                    if (response != null)
                    {
                        // clear current items in any lists
                        // list items will be refreshed online if we try to request them
                        TraktLists.ClearItemsInList(TraktSettings.Username, listId);

                        // update MovingPictures Categories and Filters menu
                        if (items.Movies != null && items.Movies.Count > 0 && IsMovingPicturesAvailableAndEnabled)
                        {
                            // we need the name of the list so get list from slug first
                            var userLists = TraktLists.GetListsForUser(TraktSettings.Username);
                            if (userLists == null) continue;

                            // get the list
                            var userList = userLists.FirstOrDefault(l => l.Ids.Trakt == listId);
                            if (userList == null) continue;

                            if (remove)
                            {
                                MovingPictures.RemoveMovieCriteriaFromCustomlistNode(userList.Name, items.Movies.First().Ids.Imdb);
                            }
                            else
                            {
                                MovingPictures.AddMovieCriteriaToCustomlistNode(userList.Name, items.Movies.First().Ids.Imdb);
                            }
                        }
                    }
                }
            })
            {
                Name = remove ? "RemoveList" : "AddList",
                IsBackground = true
            };

            listThread.Start();
        }

Same methods

TraktHelper::AddRemoveItemInList ( int listId, TraktSyncAll items, bool remove ) : void