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

RegisterExpectedShipmentsEventHandler() private static method

private static RegisterExpectedShipmentsEventHandler ( HttpRequest request ) : void
request System.Web.HttpRequest
return void
        private static void RegisterExpectedShipmentsEventHandler(HttpRequest request)
        {
            using (var clientContext = sPContext.CreateUserClientContextForSPHost())
            {
                var query = from list in clientContext.Web.Lists
                            where list.Title == "Expected Shipments"
                            select list;
                IEnumerable<List> matchingLists = clientContext.LoadQuery(query);
                clientContext.ExecuteQuery();

                List expectedShipmentsList = matchingLists.Single();

                EventReceiverDefinitionCreationInformation receiver = new EventReceiverDefinitionCreationInformation();
                receiver.ReceiverName = "ExpectedShipmentsItemUpdated";
                receiver.EventType = EventReceiverType.ItemUpdated;

            #if DEBUG
                receiver.ReceiverUrl = WebConfigurationManager.AppSettings["RERdebuggingServiceBusUrl"].ToString();
            #else
                receiver.ReceiverUrl = "https://" + request.Headers["Host"] + "/Services/RemoteEventReceiver1.svc";
            #endif

                expectedShipmentsList.EventReceivers.Add(receiver);

                clientContext.ExecuteQuery();
            }
        }