public bool DoesActionPlanResourceExistAndBelongToCustomer(Guid actionPlanId, Guid interactionId, Guid customerId) { var collectionUri = DocumentDBHelper.CreateActionPlanDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); if (client == null) { return(false); } try { var query = client.CreateDocumentQuery <long>(collectionUri, new SqlQuerySpec() { QueryText = "SELECT VALUE COUNT(1) FROM actionplans a " + "WHERE a.id = @actionPlanId " + "AND a.InteractionId = @interactionId " + "AND a.CustomerId = @customerId", Parameters = new SqlParameterCollection() { new SqlParameter("@actionPlanId", actionPlanId), new SqlParameter("@interactionId", interactionId), new SqlParameter("@customerId", customerId) } }).AsEnumerable().FirstOrDefault(); return(Convert.ToBoolean(Convert.ToInt16(query))); } catch (DocumentQueryException) { return(false); } }