public List <AddedOrUpdatedContact> AddOrUpdateContact(AddOrUpdateContactRequest addOrUpdateContactRequest) { var request = addOrUpdateContactRequest; var response = AmoMethod.Post <AddOrUpdateContactResponse>(request, _crmConfig); return(response.Response.Contacts); }
protected void ButtonUpdateMainContact_Click(object sender, EventArgs e) { var request = new AddOrUpdateContactRequest(); CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value); request.Update = new List <AddOrUpdateCrmContact>(); request.Add = new List <AddOrUpdateCrmContact>(); { var _contact = new AddOrUpdateCrmContact(); _contact.Id = crmLead.MainContactId; _contact.Name = TextBoxMainContactName.Text; _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Lead, "MainContact"); request.Update.Add(_contact); } var countContact = 0; //а теперь обойдем дополнительные контакты foreach (Control c in PanelContacts.Controls) { if (c is Table) { countContact++; var tableContact = c as Table; if (tableContact.ID != "TableMainContact") { var _contact = new AddOrUpdateCrmContact(); foreach (Control cc in tableContact.Rows[1].Cells[1].Controls) { if (cc is TextBox) { _contact.Name = (cc as TextBox).Text; } if (cc is HiddenField) { _contact.Id = Convert.ToInt64((cc as HiddenField).Value); } } _contact.LeadsId = crmLead.Id.ToString(); _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Contact, tableContact.ID.Replace("Table", "")); if (_contact.Id != null && _contact.Id > 0) { request.Update.Add(_contact); } else { request.Add.Add(_contact); } } } } _service.AddOrUpdateContact(request); LabelMsg.Visible = true; LabelMsg.CssClass = "alert alert-success"; LabelMsg.Text = "Данные по контактам обновлены"; }
private Int64 CreateContacts(long LeadId = 0) { var request = new AddOrUpdateContactRequest(); CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value); request.Update = new List <AddOrUpdateCrmContact>(); request.Add = new List <AddOrUpdateCrmContact>(); { var _contact = new AddOrUpdateCrmContact(); if (crmLead != null && crmLead.MainContactId > 0) { _contact.Id = crmLead.MainContactId; } _contact.Name = TextBoxMainContactName.Text; if (LeadId > 0) { _contact.LeadsId = LeadId.ToString(); } _contact.CompanyName = TextBoxMainCampaignName.Text; _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Lead, "MainContact"); if (crmLead != null && crmLead.MainContactId > 0) { request.Update.Add(_contact); } else { request.Add.Add(_contact); } } var countContact = 0; //а теперь обойдем дополнительные контакты foreach (Control c in PanelContacts.Controls) { if (c is Table) { countContact++; var tableContact = c as Table; if (tableContact.ID != "TableMainContact") { var _contact = new AddOrUpdateCrmContact(); foreach (Control cc in tableContact.Rows[1].Cells[1].Controls) { if (cc is TextBox) { _contact.Name = (cc as TextBox).Text; } if (cc is HiddenField) { _contact.Id = Convert.ToInt64((cc as HiddenField).Value); } } foreach (Control cc in tableContact.Rows[2].Cells[1].Controls) { if (cc is TextBox) { _contact.CompanyName = (cc as TextBox).Text; } if (cc is HiddenField) { _contact.Id = Convert.ToInt64((cc as HiddenField).Value); } } _contact.LeadsId = crmLead.Id.ToString(); _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Contact, tableContact.ID.Replace("Table", "")); if (_contact.Id != null && _contact.Id > 0) { request.Update.Add(_contact); } else { request.Add.Add(_contact); } } } } var rslt = _service.AddOrUpdateContact(request); if (rslt.FirstOrDefault() != null) { HiddenFieldMainContactId.Value = rslt.FirstOrDefault().Id.ToString(); return(rslt.FirstOrDefault().Id); } return(0); }
public async Task <IHttpActionResult> Update(AddOrUpdateContactRequest request) { request.TenantId = (await _userManager.GetUserAsync(User)).TenantId; return(Ok(await _mediator.Send(request))); }
private Int64 CreateContacts(AddedOrUpdatedLead crmLead) { var laed = _service.GetLead(crmLead.Id); var request = new AddOrUpdateContactRequest(); request.Update = new List <AddOrUpdateCrmContact>(); request.Add = new List <AddOrUpdateCrmContact>(); { var _contact = new AddOrUpdateCrmContact(); _contact.Name = TextBoxFIOLPR.Text; _contact.LeadsId = crmLead.Id.ToString(); _contact.CompanyName = TextBoxNameCampaign.Text; var CustomFields = new List <AddContactCustomField>(); CustomFields.Add(new AddContactCustomField() { Id = 232955, Values = new List <Object> { new AddCustomFieldValues() { Value = TextBoxDolgnostLPR.Text } } }); CustomFields.Add(new AddContactCustomField() { Id = 232957, Values = new List <Object> { new AddCustomFieldValuesEnum() { Value = TextBoxPhoneLPR.Text, Enum = "WORK" } } }); //352111 CustomFields.Add(new AddContactCustomField() { Id = 232959, Values = new List <Object> { new AddCustomFieldValuesEnum() { Value = TextBoxEmailLPR.Text, Enum = "WORK" } } }); //352111 //232957 _contact.CustomFields = CustomFields; if (laed.MainContactId > 0) { _contact.Id = laed.MainContactId; request.Update.Add(_contact); } else { request.Add.Add(_contact); } } var countContact = 0; var rslt = _service.AddOrUpdateContact(request); if (rslt.FirstOrDefault() != null) { //HiddenFieldMainContactId.Value = rslt.FirstOrDefault().Id.ToString(); return(rslt.FirstOrDefault().Id); } return(0); }