public static void OptInCustomer(int customerID, string email) { Exigo.WebService().UpdateCustomer(new UpdateCustomerRequest { CustomerID = customerID, Email = email, SubscribeToBroadcasts = true, SubscribeFromIPAddress = GlobalUtilities.GetClientIP() }); }
public ActionResult ManageAutoOrder(int id, ManageAutoOrderViewModel viewModel) { var customerID = Identity.Customer.CustomerID; var apiRequests = new List <ApiRequest>(); var customer = Exigo.GetCustomer(customerID); var market = GlobalSettings.Markets.AvailableMarkets.Where(c => c.Countries.Contains(Identity.Customer.Country)).FirstOrDefault(); var configuration = market.GetConfiguration().AutoOrders; var warehouseID = configuration.WarehouseID; var isExistingAutoOrder = id != 0; var paymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest() { CustomerID = Identity.Customer.CustomerID, ExcludeIncompleteMethods = true }); // Remove all items that have no quantity. viewModel.AutoOrder.Details = viewModel.AutoOrder.Details.Where(d => d.Quantity > 0).ToList(); if (!viewModel.AutoOrder.Details.Any()) { ModelState.AddModelError("Result", "Please select at least one product for your Auto Order."); } if (ModelState.Keys.Contains("Result")) { InflateManageAutoOrderViewModel(customerID, market, configuration, ref viewModel); return(View(viewModel)); } // Save New Credit Card var isUsingNewCard = viewModel.AutoOrder.AutoOrderPaymentTypeID == 0; var hasPrimaryCard = paymentMethods.Where(v => v.IsComplete).Count() > 0; if (isUsingNewCard) { var saveCCRequest = new SetAccountCreditCardTokenRequest(viewModel.NewCreditCard); // If there is one or more available payment type, save the card in the secondary card slot if (hasPrimaryCard) { saveCCRequest.CreditCardAccountType = AccountCreditCardType.Secondary; viewModel.AutoOrder.AutoOrderPaymentTypeID = AutoOrderPaymentTypes.SecondaryCreditCardOnFile; } else { viewModel.AutoOrder.AutoOrderPaymentTypeID = AutoOrderPaymentTypes.PrimaryCreditCardOnFile; } saveCCRequest.CustomerID = customerID; apiRequests.Add(saveCCRequest); } // Prepare the auto order var autoOrder = viewModel.AutoOrder; var createAutoOrderRequest = new CreateAutoOrderRequest(autoOrder) { PriceType = configuration.PriceTypeID, WarehouseID = warehouseID, Notes = !string.IsNullOrEmpty(autoOrder.Notes) ? autoOrder.Notes : string.Format("Created with the API Auto-Delivery manager at \"{0}\" on {1:u} at IP {2} using {3} {4} ({5}).", Request.Url.AbsoluteUri, DateTime.Now.ToUniversalTime(), GlobalUtilities.GetClientIP(), HttpContext.Request.Browser.Browser, HttpContext.Request.Browser.Version, HttpContext.Request.Browser.Platform), CustomerID = customerID }; apiRequests.Add(createAutoOrderRequest); try { // Process the transaction var transaction = new TransactionalRequest { TransactionRequests = apiRequests.ToArray() }; var response = Exigo.WebService().ProcessTransaction(transaction); return(RedirectToAction("AutoOrderList", new { success = "1" })); } catch (Exception ex) { ModelState.AddModelError("Result", "We were unable to save your Auto-Delivery: " + ex.Message); InflateManageAutoOrderViewModel(customerID, market, configuration, ref viewModel); return(View(viewModel)); } }
public UpdateCustomerRequest(Customer customer) { CustomerID = customer.CustomerID; CustomerType = customer.CustomerTypeID; CustomerStatus = customer.CustomerStatusID; DefaultWarehouseID = customer.DefaultWarehouseID; LanguageID = customer.LanguageID; //EntryDate = customer.CreatedDate; //BirthDate = customer.BirthDate; FirstName = customer.FirstName; // gwb:20141206 - Added. MiddleName = customer.MiddleName; LastName = customer.LastName; // gwb:20141206 - Added. NameSuffix = customer.NameSuffix; Company = customer.Company; Email = customer.Email; Phone = customer.PrimaryPhone; Phone2 = customer.SecondaryPhone; MobilePhone = customer.MobilePhone; Fax = customer.Fax; if (customer.MainAddress != null) { MainAddress1 = customer.MainAddress.Address1; MainAddress2 = customer.MainAddress.Address2; MainCity = customer.MainAddress.City; MainState = customer.MainAddress.State; MainZip = customer.MainAddress.Zip; MainCountry = customer.MainAddress.Country; } if (customer.MailingAddress != null) { MailAddress1 = customer.MailingAddress.Address1; MailAddress2 = customer.MailingAddress.Address2; MailCity = customer.MailingAddress.City; MailState = customer.MailingAddress.State; MailZip = customer.MailingAddress.Zip; MailCountry = customer.MailingAddress.Country; } if (customer.OtherAddress != null) { OtherAddress1 = customer.OtherAddress.Address1; OtherAddress2 = customer.OtherAddress.Address2; OtherCity = customer.OtherAddress.City; OtherState = customer.OtherAddress.State; OtherZip = customer.OtherAddress.Zip; OtherCountry = customer.OtherAddress.Country; } TaxID = customer.TaxID; PayableToName = customer.PayableToName; PayableType = Exigo.GetPayableType(customer.PayableTypeID); //CanLogin = customer.CanLogin; //LoginName = customer.LoginName; //LoginPassword = customer.Password; //if (customer.EnrollerID != null) //{ // InsertEnrollerTree = true; // EnrollerID = (int)customer.EnrollerID; //} //if (customer.SponsorID != null) //{ // InsertUnilevelTree = true; // SponsorID = (int)customer.SponsorID; //} if (customer.IsOptedIn) { SubscribeToBroadcasts = customer.IsOptedIn; SubscribeFromIPAddress = GlobalUtilities.GetClientIP(); } Field1 = customer.Field1; Field2 = customer.Field2; Field3 = customer.Field3; Field4 = customer.Field4; Field5 = customer.Field5; Field6 = customer.Field6; Field7 = customer.Field7; Field8 = customer.Field8; Field9 = customer.Field9; Field10 = customer.Field10; Field11 = customer.Field11; Field12 = customer.Field12; Field13 = customer.Field13; Field14 = customer.Field14; Field15 = customer.Field15; Date1 = customer.Date1; Date2 = customer.Date2; Date3 = customer.Date3; Date4 = customer.Date4; Date5 = customer.Date5; }
public CreateCustomerRequest(Customer customer) { CustomerType = customer.CustomerTypeID; CustomerStatus = customer.CustomerStatusID; DefaultWarehouseID = customer.DefaultWarehouseID; LanguageID = customer.LanguageID; EntryDate = customer.CreatedDate; // DateTime.MinValue is used as the flag to show they have opted not to save their bday info if (customer.BirthDate != DateTime.MinValue) { BirthDate = customer.BirthDate; } FirstName = customer.FirstName; MiddleName = customer.MiddleName; LastName = customer.LastName; Email = customer.Email; Phone = customer.PrimaryPhone; Phone2 = customer.SecondaryPhone; MobilePhone = customer.MobilePhone; Fax = customer.Fax; if (customer.MainAddress != null) { MainAddress1 = customer.MainAddress.Address1; MainAddress2 = customer.MainAddress.Address2; MainCity = customer.MainAddress.City; MainState = customer.MainAddress.State; MainZip = customer.MainAddress.Zip; MainCountry = customer.MainAddress.Country; } if (customer.MailingAddress != null) { MailAddress1 = customer.MailingAddress.Address1; MailAddress2 = customer.MailingAddress.Address2; MailCity = customer.MailingAddress.City; MailState = customer.MailingAddress.State; MailZip = customer.MailingAddress.Zip; MailCountry = customer.MailingAddress.Country; } if (customer.OtherAddress != null) { OtherAddress1 = customer.OtherAddress.Address1; OtherAddress2 = customer.OtherAddress.Address2; OtherCity = customer.OtherAddress.City; OtherState = customer.OtherAddress.State; OtherZip = customer.OtherAddress.Zip; OtherCountry = customer.OtherAddress.Country; } TaxID = customer.TaxID; PayableToName = customer.PayableToName; PayableType = Exigo.GetPayableType(customer.PayableTypeID); LoginName = customer.LoginName; LoginPassword = customer.Password; if (customer.EnrollerID != null) { InsertEnrollerTree = true; EnrollerID = (int)customer.EnrollerID; } if (customer.SponsorID != null) { InsertUnilevelTree = true; SponsorID = (int)customer.SponsorID; } if (customer.IsOptedIn) { SubscribeToBroadcasts = customer.IsOptedIn; SubscribeFromIPAddress = GlobalUtilities.GetClientIP(); } Field1 = customer.Field1; Field2 = customer.Field2; Field3 = customer.Field3; Field4 = customer.Field4; Field5 = customer.Field5; Field6 = customer.Field6; Field7 = customer.Field7; Field8 = customer.Field8; Field9 = customer.Field9; Field10 = customer.Field10; Field11 = customer.Field11; Field12 = customer.Field12; Field13 = customer.Field13; Field14 = customer.Field14; Field15 = customer.Field15; Date1 = customer.Date1; Date2 = customer.Date2; Date3 = customer.Date3; Date4 = customer.Date4; Date5 = customer.Date5; }