Exemple #1
0
        public static EntityReference GetCompanyClassificationReferenceByName(this IOrganizationService service, string companyClassification)
        {
            Guard.ArgumentNotNullOrEmpty(companyClassification, "companyClassification");

            if (companyClassification == "Uncategorized")
            {
                return(null);
            }

            var productTypeNameCondition = ConditionExpressionHelper.CreateEqualsCondition("xv_name", companyClassification);
            var filter = new FilterExpression();

            filter.Conditions.Add(productTypeNameCondition);

            var query = new QueryExpression(xv_firmenklassifizierung.EntityLogicalName);

            query.Criteria.AddFilter(filter);

            var productTypeEntity = service.RetrieveMultiple(query)
                                    .Entities
                                    .FirstOrDefault();

            if (productTypeEntity == null)
            {
                throw new CrmEntityNotFoundException(string.Format("Company classification '{0}' was not found.", companyClassification));
            }

            return(productTypeEntity.ToEntityReference());
        }
Exemple #2
0
        public static IEnumerable <EntityReference> GetQuoteItemsByQuoteId(this IOrganizationService service, EntityReference quoteReference)
        {
            var quoteIdCondition = ConditionExpressionHelper.CreateEqualsCondition("quoteid", quoteReference.Id);

            var filter = new FilterExpression();

            filter.Conditions.Add(quoteIdCondition);

            var query = new QueryExpression(QuoteDetail.EntityLogicalName);

            query.Criteria.AddFilter(filter);

            return(service.RetrieveMultiple(query)
                   .Entities
                   .Select(item => item.ToEntityReference()));
        }
Exemple #3
0
        public static IEnumerable <EntityReference> GetOpportunityItemsByOpportunityId(this IOrganizationService service, EntityReference opportunityReference)
        {
            var opportunityIdCondition = ConditionExpressionHelper.CreateEqualsCondition("opportunityid", opportunityReference.Id);

            var filter = new FilterExpression();

            filter.Conditions.Add(opportunityIdCondition);

            var query = new QueryExpression(OpportunityProduct.EntityLogicalName);

            query.Criteria.AddFilter(filter);

            return(service.RetrieveMultiple(query)
                   .Entities
                   .Select(item => item.ToEntityReference()));
        }
Exemple #4
0
        public static EntityReference GetProductTypeReferenceByName(this IOrganizationService service, string productTypeName)
        {
            Guard.ArgumentNotNullOrEmpty(productTypeName, "productTypeName");

            var productTypeNameCondition = ConditionExpressionHelper.CreateEqualsCondition("xv_name", productTypeName);
            var filter = new FilterExpression();

            filter.Conditions.Add(productTypeNameCondition);

            var query = new QueryExpression(xv_gattungen.EntityLogicalName);

            query.Criteria.AddFilter(filter);

            var productTypeEntity = service.RetrieveMultiple(query)
                                    .Entities
                                    .FirstOrDefault();

            if (productTypeEntity == null)
            {
                throw new CrmEntityNotFoundException(string.Format("Product type '{0}' was not found.", productTypeName));
            }

            return(productTypeEntity.ToEntityReference());
        }