public async Task <HttpResponseMessage> Post([FromBody] WebhookFeedFB data)
        {
            StreamReader reader  = new StreamReader(HttpContext.Current.Request.InputStream);
            string       json    = reader.ReadToEnd();
            bool         isValid = ValidateSignatureWithPayload(json, HttpContext.Current.Request.Headers["X-Hub-Signature"], this.appSecret);

            if (isValid)
            {
                await SendDataAsync(data);

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }

            return(new HttpResponseMessage(HttpStatusCode.BadRequest));
        }
        /// <summary>
        /// convert facebook data to table object
        /// </summary>
        /// <param name="data">the data comng from server</param>
        /// <returns>Table object</returns>
        private async Task SendDataAsync(WebhookFeedFB data)
        {
            string jobId;

            foreach (Entry entry in data.Entry)
            {
                if (PageJobMapping.ContainsKey(entry.Id))
                {
                    jobId = PageJobMapping[entry.Id].RowKey;
                }
                else
                {
                    Trace.TraceInformation($"Page Id: {entry.Id}");
                    Expression <Func <PageJobEntity, bool> > filter = (entity => entity.PartitionKey == entry.Id);
                    PageJobMappingTable = azureTableProvider.GetAzureTableReference(Settings.PageJobMappingTableName);
                    List <PageJobEntity> pageJobEntityList = await azureTableProvider.QueryEntitiesAsync <PageJobEntity>(PageJobMappingTable, filter);

                    Trace.TraceInformation($"Fetched entries from Table: {pageJobEntityList.Count}");
                    PageJobEntity pageJobEntity = pageJobEntityList?[0];
                    PageJobMapping.Add(pageJobEntity?.PartitionKey, pageJobEntity);
                    jobId = pageJobEntity?.RowKey;
                }

                foreach (Change change in entry.Changes)
                {
                    if (change.Value != null && change.Value.PostId != null)
                    {
                        await eventApiClient.OnWebhookEvent(Settings.TenantId, jobId, $"{change.Value?.CreatedTime}", $"{change.Value?.PostId}", "update");
                    }
                    else
                    {
                        Trace.TraceWarning("No post id");
                    }
                }
            }
        }
 public void DataModelTestFBWebhook()
 {
     // Message Comment by Page
     string        data    = File.ReadAllText(@"FakeData\FakeWebhookFeedData.json");
     WebhookFeedFB webhook = JsonConvert.DeserializeObject <WebhookFeedFB>(data);
 }