public Entity CreateAccount(Entity account, string companyName, string City, string Address, string Zip, string State, string phone, string phone1, string extId, string email, Money revenue, params object[] custom) { bool create_mode = false; if (account == null) { account = new Entity(); account.LogicalName = "account"; create_mode = true; } account["name"] = companyName; setStrValue(account, "address1_line1", Address); setStrValue(account, "address1_city", City); account["address1_postalcode"] = Zip; account["address1_stateorprovince"] = State; account["telephone1"] = phone; account["telephone2"] = phone1; account["msdyn_externalaccountid"] = extId; account["emailaddress1"] = email; account["revenue"] = revenue; string fileName = null; foreach (object s in custom) { if (fileName == null) { fileName = s as string; } else { account[fileName] = s; fileName = null; } } if (create_mode) { account.Id = CRMOrganizationService.Create(account); } else { CRMOrganizationService.Update(account); } return(account); }
public Entity CreateContact(Entity contact, string firstName, string lastName, string email, string phoneNumber, string title, Entity account, bool isPrimary) { bool create_mode = false; if (contact == null) { contact = new Entity(); contact.LogicalName = "contact"; create_mode = true; } if (!string.IsNullOrEmpty(firstName)) { contact["firstname"] = firstName; } if (!string.IsNullOrEmpty(lastName)) { contact["lastname"] = lastName; } contact["emailaddress1"] = email; contact["telephone1"] = phoneNumber; contact["jobtitle"] = title; contact["parentcustomerid"] = new EntityReference("account", account.Id); if (create_mode) { contact.Id = CRMOrganizationService.Create(contact); } else { CRMOrganizationService.Update(contact); } if (isPrimary) { account["primarycontactid"] = new EntityReference("contact", contact.Id); CRMOrganizationService.Update(account); } Logger("contact created, id= " + contact.Id); return(contact); }
public void Update(Entity entity) { CRMOrganizationService.Update(entity); }