ChainStoreWeb.Utilities.SharePointComponentDeployer.ChangeCustomActionRegistration C# (CSharp) Method

ChangeCustomActionRegistration() private static method

private static ChangeCustomActionRegistration ( ) : void
return void
        private static void ChangeCustomActionRegistration()
        {
            using (var clientContext = sPContext.CreateUserClientContextForSPHost())
            {
                var query = from action in clientContext.Web.UserCustomActions
                            where action.Name == "6601a902-f458-4757-9000-09f23eaa5386.AddEmployeeToCorpDB"
                            select action;
                IEnumerable<UserCustomAction> matchingActions = clientContext.LoadQuery(query);
                clientContext.ExecuteQuery();

                UserCustomAction webScopedEmployeeAction = matchingActions.Single();

                var queryForList = from list in clientContext.Web.Lists
                                   where list.Title == "Local Employees"
                                   select list;
                IEnumerable<List> matchingLists = clientContext.LoadQuery(queryForList);
                clientContext.ExecuteQuery();

                List employeeList = matchingLists.First();
                var listActions = employeeList.UserCustomActions;
                clientContext.Load(listActions);
                listActions.Clear();

                var listScopedEmployeeAction = listActions.Add();

                listScopedEmployeeAction.Title = webScopedEmployeeAction.Title;
                listScopedEmployeeAction.Location = webScopedEmployeeAction.Location;
                listScopedEmployeeAction.Sequence = webScopedEmployeeAction.Sequence;
                listScopedEmployeeAction.CommandUIExtension = webScopedEmployeeAction.CommandUIExtension;
                listScopedEmployeeAction.Update();

                webScopedEmployeeAction.DeleteObject();

                clientContext.ExecuteQuery();
            }
        }