protected void Page_Load(object sender, EventArgs e)
        {
            // button controls
            btnApplyCustomization.Click   += BtnApplyCustomization_Click;
            btnDisableCustomization.Click += BtnDisableCustomization_Click;

            spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var clientContext = spContext.CreateAppOnlyClientContextForSPAppWeb())
            {
                FixLookupColumns(clientContext);
            }
        }
        private async Task ReactToWebHookDeletion()
        {
            string target = Request["__EVENTTARGET"];

            if (target == "deletewebhook")
            {
                using (var cc = spContext.CreateAppOnlyClientContextForSPAppWeb())
                {
                    string[] parameters = Request["__EVENTARGUMENT"].Split(new string[] { "||" }, StringSplitOptions.None);
                    string   id         = parameters[0];
                    string   listId     = parameters[1];

                    // Hookup event to capture access token
                    cc.ExecutingWebRequest += Cc_ExecutingWebRequest;
                    // Just load the Url property to trigger the ExecutingWebRequest event handler to fire
                    cc.Load(cc.Web, w => w.Url);
                    cc.ExecuteQueryRetry();

                    WebHookManager webHookManager = new WebHookManager();
                    // delete the web hook
                    if (await webHookManager.DeleteListWebHookAsync(cc.Web.Url, listId, id, this.accessToken))
                    {
                        using (SharePointWebHooks dbContext = new SharePointWebHooks())
                        {
                            var webHookRow = await dbContext.ListWebHooks.FindAsync(new Guid(id));

                            if (webHookRow != null)
                            {
                                dbContext.ListWebHooks.Remove(webHookRow);
                                var saveResult = await dbContext.SaveChangesAsync();
                            }
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // button controls
            btnApplyCustomization.Click   += BtnApplyCustomization_Click;
            btnDisableCustomization.Click += BtnDisableCustomization_Click;

            spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var cc = spContext.CreateAppOnlyClientContextForSPAppWeb())
            {
                RegisterAddingWebHookEvent(cc);
                FixLookupColumns(cc);
                RegisterAsyncTask(new PageAsyncTask(ReactToWebHookDeletion));
                RegisterAsyncTask(new PageAsyncTask(ExecuteWebHooksLogic));
            }
        }