VirtoCommerce.Web.Models.Services.CustomerService.CreateCustomerAsync C# (CSharp) Method

CreateCustomerAsync() public method

public CreateCustomerAsync ( Customer customer ) : Task
customer VirtoCommerce.Web.Models.Customer
return Task
        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();
        }
        #endregion