public async Task<Customer> CreateCustomerAsync(string email, string firstName, string lastName, string id, ICollection<CustomerAddress> addresses) { var contact = new Contact { FullName = string.Format("{0} {1}", firstName, lastName) }; contact.Emails = new List<string> { email }; if (addresses != null) { contact.Addresses = new List<Address>(); foreach (var address in addresses) { contact.Addresses.Add(address.AsServiceModel()); } } contact.Id = id; contact = await this._customerClient.CreateContactAsync(contact); return contact.AsWebModel(); }
public Task<Contact> CreateContactAsync(Contact contact) { return SendAsync<Contact, Contact>( CreateRequestUri(RelativePaths.SendContant), HttpMethod.Post, contact); }
public async Task<Customer> CreateCustomerAsync(Customer customer) { Contact contact = null; if (string.IsNullOrEmpty(customer.FirstName) && string.IsNullOrEmpty(customer.LastName)) { contact = new Contact { FullName = customer.Email }; } else { contact = new Contact { FullName = string.Format("{0} {1}", customer.FirstName, customer.LastName) }; } contact.Emails = new List<string> { customer.Email }; if (customer.Addresses != null) { contact.Addresses = new List<Address>(); foreach (var address in customer.Addresses) { contact.Addresses.Add(address.AsServiceModel()); } } contact.Id = customer.Id; contact.DynamicProperties = customer.DynamicProperties.Select(p => p.ToServiceModel()).ToArray(); contact = await this._customerClient.CreateContactAsync(contact); return contact.AsWebModel(); }