public async Task <CustomerAuthTicket> AddCustomerAccount(CustomerAccountAndAuthInfo account, Credit credit, Wishlist wishlist) { var notes = new List <string>(); var customerAccountResource = new CustomerAccountResource(_apiContext); var newAccount = await customerAccountResource.AddAccountAndLoginAsync(account); notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount. AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "AddAccountAndLoginAsync")); var customerContactResource = new CustomerContactResource(_apiContext); foreach (var contact in account.Account.Contacts) { contact.AccountId = newAccount.CustomerAccount.Id; var newContact = await customerContactResource.AddAccountContactAsync(contact, newAccount.CustomerAccount.Id); notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount. AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "AddAccountContactAsync")); } var customerCreditResource = new CreditResource(_apiContext); credit.CustomerId = newAccount.CustomerAccount.Id; var newCredit = await customerCreditResource.AddCreditAsync(credit); notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount. AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "AddCreditAsync")); var wishListItemResource = new WishlistResource(_apiContext); wishlist.CustomerAccountId = newAccount.CustomerAccount.Id; var newWishList = await wishListItemResource.CreateWishlistAsync(wishlist); notes.Add(string.Format("updatedby:{0},updatedDate:{1},action:{2}", newAccount.CustomerAccount. AuditInfo.UpdateBy, newAccount.CustomerAccount.AuditInfo.UpdateDate, "CreateWishlistAsync")); var customerSegmentResource = new Mozu.Api.Resources.Commerce.Customer.CustomerSegmentResource(_apiContext); // var segmentAccount = await customerSegmentResource.AddSegmentAccountsAsync() var customerNoteResource = new CustomerNoteResource(_apiContext); foreach (var note in notes) { var newNote = await customerNoteResource.AddAccountNoteAsync( new CustomerNote() { Content = note }, newAccount.CustomerAccount.Id); } return(newAccount); }
public async Task <CustomerContact> AddCustomerContact(int accountId, CustomerContact contact, int tenantId, int?siteId, int?masterCatalogId) { _apiContext = new ApiContext(tenantId, siteId); var customerContactResource = new CustomerContactResource(_apiContext); var newContact = await customerContactResource.AddAccountContactAsync(contact, accountId); return(newContact); }