public async Task DeleteJob()

in Twitter/Connector/Controllers/ConnectorJobController.cs [70:95]


        public async Task<HttpResponseMessage> DeleteJob([FromUri] string jobId)
        {
            CloudTable jobMappingTable = azureTableProvider.GetAzureTableReference(Settings.PageJobMappingTableName);

            Expression<Func<PageJobEntity, bool>> filter = (entity => entity.RowKey == jobId);
            List<PageJobEntity> pageJobEntityList = await azureTableProvider.QueryEntitiesAsync<PageJobEntity>(jobMappingTable, filter);

            if (!pageJobEntityList.Any())
            {
                return new HttpResponseMessage(HttpStatusCode.NotFound);
            }
            PageJobEntity pageJobEntity = pageJobEntityList?[0];

            bool unsubscribed = await connectorSourceProvider.Unsubscribe(pageJobEntity.SourceInfo);
            Trace.TraceInformation("Job with JobId: {0} successfully unsubscribed to webhook", jobId);

            if (unsubscribed == false)
            {
                return new HttpResponseMessage(HttpStatusCode.InternalServerError);
            }

            await azureTableProvider.DeleteEntityAsync<PageJobEntity>(jobMappingTable, pageJobEntity);
            Trace.TraceInformation("Job with JobId: {0} successfully deleted", jobId);

            return new HttpResponseMessage(HttpStatusCode.OK);
        }