Beispiel #1
0
        /// <summary>
        /// Pushes the information to the <c>crm</c>
        /// </summary>
        /// <param name="crm">
        /// The <see cref="AgileCRM"/> instance
        /// </param>
        /// <returns>
        /// A <see cref="Task"/> representing the asynchronous operation.
        /// </returns>
        public async Task PushAsync(AgileCRM crm)
        {
            var exists = await this.ExistsAsync(crm).ConfigureAwait(false);

            if (!exists)
            {
                var newPersonRequest = new NewPersonRequest(this);
                var updatedContact   = await crm.RequestAsync("contacts", HttpMethod.Post, JsonConvert.SerializeObject(newPersonRequest)).ConfigureAwait(false);

                this.Contact.Update(JsonConvert.DeserializeObject <Contact>(updatedContact));
            }
            else
            {
                // make sure the contact id is initialized
                if (this.Contact.Id == 0)
                {
                    var person = new Person(this.Email);
                    await person.PullAsync(crm).ConfigureAwait(false);

                    this.Contact.Id = person.Contact.Id;
                }

                // update properties
                var updatePropertiesRequest = new UpdateContactPropertiesRequest(this.Contact);
                await crm.RequestAsync("contacts/edit-properties", HttpMethod.Put, JsonConvert.SerializeObject(updatePropertiesRequest)).ConfigureAwait(false);

                // update lead score
                var updateLeadScoreRequest = new UpdateLeadScoreRequest(this.Contact);
                await crm.RequestAsync("contacts/edit/lead-score", HttpMethod.Put, JsonConvert.SerializeObject(updateLeadScoreRequest)).ConfigureAwait(false);

                // update star value
                var updateStarValueRequest = new UpdateStarValueRequest(this.Contact);
                await crm.RequestAsync("contacts/edit/add-star", HttpMethod.Put, JsonConvert.SerializeObject(updateStarValueRequest)).ConfigureAwait(false);
            }
        }
        public UpdateLeadScoreResponse UpdateLeadScore(UpdateLeadScoreRequest request)
        {
            LeadScore leadScore = Mapper.Map <LeadScoreViewModel, LeadScore>(request.LeadScoreViewModel);

            //isLeadScoreValid(leadScore);
            leadScoreRepository.Update(leadScore);
            unitOfWork.Commit();
            Logger.Current.Informational("LeadScore Updated successfully.");
            return(new UpdateLeadScoreResponse());
        }