Example #1
0
        public JsonResult RetrieveMultipleEntities([FromUri] ODataQuery oDataQuery)
        {
            log.Info("Entered RetrieveMultipleEntities ");
            ODataQuery odataQueryObject = GetODataQueryObject(Request, "ODataQuery");

            try
            {
                RetrieveMultipleResponse retrieveMultipleResponse = EntityApiUtils.RetrieveEntities(ServiceProxy,
                                                                                                    odataQueryObject);

                ResultSet resultSet = GetResultSet(retrieveMultipleResponse);
                log.Info("Exiting RetrieveMultipleEntities ");
                return(new JsonResult
                {
                    Data = resultSet,
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            catch (Exception e)
            {
                log.Info("Exiting RetrieveMultipleEntities with message ");
                return(new JsonResult
                {
                    Data = e.Message
                });
            }
        }
Example #2
0
        private void PopulateAllContactsFromFilter(EmailEntity emailEntity, EntityCollection activityPartyBccColl)
        {
            var jArrayToAllFilter    = (JArray)emailEntity.ToAllFilter;
            var jobjToAllFilterArray = jArrayToAllFilter.Children <JObject>();
            var filterConditions     = new List <FilterCondition>();

            foreach (var jobjToAllFilter in jobjToAllFilterArray)
            {
                var attributeName  = getPropertyValue(jobjToAllFilter, "attributeName");
                var attributeValue = getPropertyValue(jobjToAllFilter, "attributeValue");
                var operatorValue  = getPropertyValue(jobjToAllFilter, "operator");
                var attributeType  = getPropertyValue(jobjToAllFilter, "attributeType");
                filterConditions.Add(new FilterCondition()
                {
                    attributeName  = attributeName,
                    attributeValue = attributeValue,
                    attributeType  = attributeType,
                    Operator       = operatorValue
                });
            }

            var odataQueryObject = new ODataQuery()
            {
                Columns          = new string[] { "contactid" },
                EntityName       = "contact",
                FilterConditions = filterConditions
            };

            var retrieveMultipleResponse = EntityApiUtils.RetrieveEntities(ServiceProxy, odataQueryObject);

            foreach (var entity in retrieveMultipleResponse.EntityCollection.Entities)
            {
                foreach (var attribute in entity.Attributes)
                {
                    var toContactId     = (Guid)attribute.Value;
                    var activityPartyTo = new Entity("activityparty");
                    activityPartyTo.Attributes.Add("partyid", new EntityReference("contact", toContactId));
                    activityPartyBccColl.Entities.Add(activityPartyTo);
                }
            }
        }