public static List <ViewModels.Endorsement> GetEndorsements(string licenceId, IDynamicsClient dynamicsClient)
        {
            var    endorsementsList = new List <ViewModels.Endorsement>();
            string filter           = $"_adoxio_licence_value eq {licenceId} and statuscode ne {(int)EndorsementStatus.Cancelled}";

            string[] expand = { "adoxio_ApplicationType" };
            try
            {
                MicrosoftDynamicsCRMadoxioEndorsementCollection endorsementsCollection = dynamicsClient.Endorsements.Get(filter: filter, expand: expand);
                if (endorsementsCollection.Value.Count > 0)
                {
                    foreach (var item in endorsementsCollection.Value)
                    {
                        if (item.AdoxioApplicationType != null)
                        {
                            var endorsement = new ViewModels.Endorsement
                            {
                                ApplicationTypeId   = item.AdoxioApplicationType.AdoxioApplicationtypeid,
                                ApplicationTypeName = item.AdoxioApplicationType.AdoxioName,
                                EndorsementId       = item.AdoxioEndorsementid,
                                EndorsementName     = item.AdoxioName
                            };
                            endorsementsList.Add(endorsement);
                        }
                    }
                }
            }
            catch (HttpOperationException httpOperationException)
            {
                Log.Logger.Error(httpOperationException, $"Error getting endorsements for licence {licenceId}");
            }

            return(endorsementsList);
        }
Exemple #2
0
        public static List <ViewModels.Endorsement> GetEndorsements(string licenceId, IDynamicsClient dynamicsClient)
        {
            var    endorsementsList = new List <ViewModels.Endorsement>();
            string filter           = $"_adoxio_licence_value eq {licenceId}";

            string[] expand = { "adoxio_ApplicationType" };
            MicrosoftDynamicsCRMadoxioEndorsementCollection endorsementsCollection = dynamicsClient.Endorsements.Get(filter: filter, expand: expand);

            if (endorsementsCollection.Value.Count > 0)
            {
                foreach (var item in endorsementsCollection.Value)
                {
                    if (item.AdoxioApplicationType != null)
                    {
                        var endorsement = new ViewModels.Endorsement
                        {
                            ApplicationTypeId   = item.AdoxioApplicationType.AdoxioApplicationtypeid,
                            ApplicationTypeName = item.AdoxioApplicationType.AdoxioName,
                            EndorsementId       = item.AdoxioEndorsementid,
                            EndorsementName     = item.AdoxioName
                        };
                        endorsementsList.Add(endorsement);
                    }
                }
            }

            return(endorsementsList);
        }