Esempio n. 1
0
 public static void CopyValues(this MicrosoftDynamicsCRMadoxioLicenseechangelog toDynamics, LicenseeChangeLog fromVM)
 {
     toDynamics.AdoxioChangetype            = (int?)fromVM.ChangeType;
     toDynamics.AdoxioBusinesstype          = (int?)fromVM.BusinessType;
     toDynamics.AdoxioIsdirectornew         = fromVM.IsDirectorNew;
     toDynamics.AdoxioIsdirectorold         = fromVM.IsDirectorOld;
     toDynamics.AdoxioIsmanagernew          = fromVM.IsManagerNew;
     toDynamics.AdoxioIsmanagerold          = fromVM.IsManagerOld;
     toDynamics.AdoxioIsofficernew          = fromVM.IsOfficerNew;
     toDynamics.AdoxioIsofficerold          = fromVM.IsOfficerOld;
     toDynamics.AdoxioIsshareholdernew      = fromVM.IsShareholderNew;
     toDynamics.AdoxioIsshareholderold      = fromVM.IsShareholderOld;
     toDynamics.AdoxioIstrusteenew          = fromVM.IsTrusteeNew;
     toDynamics.AdoxioIstrusteeold          = fromVM.IsTrusteeOld;
     toDynamics.AdoxioNumberofsharesnew     = fromVM.NumberofSharesNew;
     toDynamics.AdoxioNumberofsharesold     = fromVM.NumberofSharesOld;
     toDynamics.AdoxioTotalsharesnew        = fromVM.TotalSharesNew;
     toDynamics.AdoxioTotalsharesold        = fromVM.NumberofSharesOld;
     toDynamics.AdoxioEmailnew              = fromVM.EmailNew;
     toDynamics.AdoxioEmailold              = fromVM.EmailOld;
     toDynamics.AdoxioFirstnamenew          = fromVM.FirstNameNew;
     toDynamics.AdoxioFirstnameold          = fromVM.FirstNameOld;
     toDynamics.AdoxioLastnamenew           = fromVM.LastNameNew;
     toDynamics.AdoxioLastnameold           = fromVM.LastNameOld;
     toDynamics.AdoxioBusinessnamenew       = fromVM.BusinessNameNew;
     toDynamics.AdoxioBusinesnameold        = fromVM.BusinessNameOld;
     toDynamics.AdoxioDateofbirthnew        = fromVM.DateofBirthNew;
     toDynamics.AdoxioDateofbirthold        = fromVM.DateofBirthOld;
     toDynamics.AdoxioInterestpercentagenew = fromVM.InterestPercentageNew;
     toDynamics.AdoxioInterestpercentageold = fromVM.InterestPercentageOld;
 }
Esempio n. 2
0
        public static LicenseeChangeLog ToViewModel(this MicrosoftDynamicsCRMadoxioLicenseechangelog changeLog)
        {
            var result = new LicenseeChangeLog()
            {
                Id                         = changeLog.AdoxioLicenseechangelogid,
                ChangeType                 = (LicenseeChangeType?)changeLog.AdoxioChangetype,
                BusinessType               = (AdoxioApplicantTypeCodes?)changeLog.AdoxioBusinesstype,
                IsDirectorNew              = changeLog.AdoxioIsdirectornew,
                IsDirectorOld              = changeLog.AdoxioIsdirectorold,
                IsManagerNew               = changeLog.AdoxioIsmanagernew,
                IsManagerOld               = changeLog.AdoxioIsmanagerold,
                IsOfficerNew               = changeLog.AdoxioIsofficernew,
                IsOfficerOld               = changeLog.AdoxioIsofficerold,
                IsOwnerNew                 = changeLog.AdoxioIsownernew,
                IsOwnerOld                 = changeLog.AdoxioIsownerold,
                IsShareholderNew           = changeLog.AdoxioIsshareholdernew,
                IsShareholderOld           = changeLog.AdoxioIsshareholderold,
                IsTrusteeNew               = changeLog.AdoxioIstrusteenew,
                IsTrusteeOld               = changeLog.AdoxioIstrusteeold,
                NumberofSharesNew          = changeLog.AdoxioNumberofsharesnew,
                NumberofSharesOld          = changeLog.AdoxioNumberofsharesold,
                NumberOfNonVotingSharesNew = changeLog.AdoxioNumberofnonvotingsharesnew,
                NumberOfNonVotingSharesOld = changeLog.AdoxioNumberofnonvotingsharesold,
                TotalSharesNew             = changeLog.AdoxioTotalsharesnew,
                TotalSharesOld             = changeLog.AdoxioTotalsharesold,
                EmailNew                   = changeLog.AdoxioEmailnew,
                EmailOld                   = changeLog.AdoxioEmailold,
                FirstNameNew               = changeLog.AdoxioFirstnamenew,
                FirstNameOld               = changeLog.AdoxioFirstnameold,
                LastNameNew                = changeLog.AdoxioLastnamenew,
                LastNameOld                = changeLog.AdoxioLastnameold,
                BusinessNameNew            = changeLog.AdoxioBusinessnamenew,
                BusinessNameOld            = changeLog.AdoxioBusinesnameold,
                InterestPercentageNew      = changeLog.AdoxioInterestpercentagenew,
                InterestPercentageOld      = changeLog.AdoxioInterestpercentageold,

                DateofBirthNew = changeLog.AdoxioDateofbirthnew,
                DateofBirthOld = changeLog.AdoxioDateofbirthold,
                TitleOld       = changeLog.AdoxioTitleold,
                TitleNew       = changeLog.AdoxioTitlenew,

                LegalEntityId             = changeLog._adoxioLegalentityidValue,
                ParentLegalEntityId       = changeLog._adoxioParentlegalentityidValue,
                ParentLicenseeChangeLogId = changeLog._adoxioParentlinceseechangelogidValue, // Dynamics has a typo for this
                NumberOfMembers           = changeLog.AdoxioNumberofmembers,
                AnnualMembershipFee       = changeLog.AdoxioAnnualmembershipfee,
            };

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Update entity in adoxio_licenseechangelogs
        /// </summary>
        /// <param name='adoxioLicenseechangelogid'>
        /// key: adoxio_licenseechangelogid of adoxio_licenseechangelog
        /// </param>
        /// <param name='body'>
        /// New property values
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="HttpOperationException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <HttpOperationResponse> UpdateWithHttpMessagesAsync(string adoxioLicenseechangelogid, MicrosoftDynamicsCRMadoxioLicenseechangelog body, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (adoxioLicenseechangelogid == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "adoxioLicenseechangelogid");
            }
            if (body == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "body");
            }
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("adoxioLicenseechangelogid", adoxioLicenseechangelogid);
                tracingParameters.Add("body", body);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
            }
            // Construct URL
            var _baseUrl = Client.BaseUri.AbsoluteUri;
            var _url     = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "adoxio_licenseechangelogs({adoxio_licenseechangelogid})").ToString();

            _url = _url.Replace("{adoxio_licenseechangelogid}", System.Uri.EscapeDataString(adoxioLicenseechangelogid));
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("PATCH");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            if (body != null)
            {
                _requestContent      = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings);
                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
                _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
            }
            // Set Credentials
            if (Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 204)
            {
                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                if (_httpResponse.Content != null)
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                }
                else
                {
                    _responseContent = string.Empty;
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new HttpOperationResponse();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
Esempio n. 4
0
 /// <summary>
 /// Update entity in adoxio_licenseechangelogs
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='adoxioLicenseechangelogid'>
 /// key: adoxio_licenseechangelogid of adoxio_licenseechangelog
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 /// <param name='customHeaders'>
 /// Headers that will be added to request.
 /// </param>
 public static HttpOperationResponse UpdateWithHttpMessages(this ILicenseechangelogs operations, string adoxioLicenseechangelogid, MicrosoftDynamicsCRMadoxioLicenseechangelog body, Dictionary <string, List <string> > customHeaders = null)
 {
     return(operations.UpdateWithHttpMessagesAsync(adoxioLicenseechangelogid, body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult());
 }
Esempio n. 5
0
 /// <summary>
 /// Update entity in adoxio_licenseechangelogs
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='adoxioLicenseechangelogid'>
 /// key: adoxio_licenseechangelogid of adoxio_licenseechangelog
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task UpdateAsync(this ILicenseechangelogs operations, string adoxioLicenseechangelogid, MicrosoftDynamicsCRMadoxioLicenseechangelog body, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.UpdateWithHttpMessagesAsync(adoxioLicenseechangelogid, body, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Esempio n. 6
0
 /// <summary>
 /// Update entity in adoxio_licenseechangelogs
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='adoxioLicenseechangelogid'>
 /// key: adoxio_licenseechangelogid of adoxio_licenseechangelog
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 public static void Update(this ILicenseechangelogs operations, string adoxioLicenseechangelogid, MicrosoftDynamicsCRMadoxioLicenseechangelog body)
 {
     operations.UpdateAsync(adoxioLicenseechangelogid, body).GetAwaiter().GetResult();
 }
Esempio n. 7
0
 /// <summary>
 /// Add new entity to adoxio_licenseechangelogs
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 /// <param name='customHeaders'>
 /// Headers that will be added to request.
 /// </param>
 public static HttpOperationResponse <MicrosoftDynamicsCRMadoxioLicenseechangelog> CreateWithHttpMessages(this ILicenseechangelogs operations, MicrosoftDynamicsCRMadoxioLicenseechangelog body, string prefer = "return=representation", Dictionary <string, List <string> > customHeaders = null)
 {
     return(operations.CreateWithHttpMessagesAsync(body, prefer, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult());
 }
Esempio n. 8
0
 /// <summary>
 /// Add new entity to adoxio_licenseechangelogs
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <MicrosoftDynamicsCRMadoxioLicenseechangelog> CreateAsync(this ILicenseechangelogs operations, MicrosoftDynamicsCRMadoxioLicenseechangelog body, string prefer = "return=representation", CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(body, prefer, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Add new entity to adoxio_licenseechangelogs
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 public static MicrosoftDynamicsCRMadoxioLicenseechangelog Create(this ILicenseechangelogs operations, MicrosoftDynamicsCRMadoxioLicenseechangelog body, string prefer = "return=representation")
 {
     return(operations.CreateAsync(body, prefer).GetAwaiter().GetResult());
 }
Esempio n. 10
0
        private void SaveChangeObjects(LicenseeChangeLog node, string applicationId, string parentLegalEntityId = null, string parentChangeLogId = null)
        {
            if (node.ChangeType != LicenseeChangeType.unchanged)
            {
                MicrosoftDynamicsCRMadoxioLicenseechangelog patchEntity = new MicrosoftDynamicsCRMadoxioLicenseechangelog();
                patchEntity.CopyValues(node);
                node.ApplicationId = applicationId;
                if (parentLegalEntityId != null)
                {
                    node.ParentLegalEntityId = parentLegalEntityId;
                }
                if (parentChangeLogId != null)
                {
                    node.ParentLinceseeChangeLogId = parentChangeLogId;
                }

                if (string.IsNullOrEmpty(node.Id)) // create
                {
                    // bind to Parent legal entity
                    if (!string.IsNullOrEmpty(node.ParentLegalEntityId))
                    {
                        patchEntity.ParentLegalEntityOdataBind = _dynamicsClient.GetEntityURI("adoxio_legalentities", node.ParentLegalEntityId);
                    }
                    // bind to legal entity
                    if (!string.IsNullOrEmpty(node.LegalEntityId))
                    {
                        patchEntity.LegalEntityIdOdataBind = _dynamicsClient.GetEntityURI("adoxio_legalentities", node.LegalEntityId);
                    }

                    // bind to parent licensee change log
                    if (!string.IsNullOrEmpty(node.ParentLinceseeChangeLogId))
                    {
                        patchEntity.ParentLinceseeChangeLogOdataBind = _dynamicsClient.GetEntityURI("adoxio_licenseechangelogs", node.ParentLinceseeChangeLogId);
                    }


                    // bind to application
                    if (!string.IsNullOrEmpty(node.ApplicationId))
                    {
                        patchEntity.ApplicationOdataBind = _dynamicsClient.GetEntityURI("adoxio_applications", node.ApplicationId);
                        parentLegalEntityId = node.LegalEntityId;
                    }

                    try
                    {
                        var result = _dynamicsClient.Licenseechangelogs.Create(patchEntity);
                        parentChangeLogId = result.AdoxioLicenseechangelogid;
                    }
                    catch (HttpOperationException httpOperationException)
                    {
                        _logger.LogError(httpOperationException, $"Error saving LicenseeChangeLog: {httpOperationException.Request.Content} Response: {httpOperationException.Response.Content}");
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, $"Unexpected Exception while adding LegalEntityOwned reference to legal entity");
                    }
                }
                else // update
                {
                    // bind to application
                    if (!string.IsNullOrEmpty(node.ApplicationId))
                    {
                        patchEntity.ApplicationOdataBind = _dynamicsClient.GetEntityURI("adoxio_applications", node.ApplicationId);
                    }


                    try
                    {
                        _dynamicsClient.Licenseechangelogs.Update(node.Id, patchEntity);
                        var result = _dynamicsClient.Licenseechangelogs.GetByKey(node.Id);
                        parentChangeLogId   = result.AdoxioLicenseechangelogid;
                        parentLegalEntityId = node.LegalEntityId;
                    }
                    catch (HttpOperationException httpOperationException)
                    {
                        _logger.LogError(httpOperationException, $"Error saving LicenseeChangeLog: {httpOperationException.Request.Content} Response: {httpOperationException.Response.Content}");
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, $"Unexpected Exception while saving LicenseeChangeLog");
                    }
                }
            }
            else
            {
                parentLegalEntityId = node.LegalEntityId;
                parentChangeLogId   = node.Id;
            }

            if (node.Children != null)
            {
                foreach (var item in node.Children)
                {
                    SaveChangeObjects(item, applicationId, parentLegalEntityId, parentChangeLogId);
                }
            }
        }