/// <summary> /// Submits the specified formid. /// </summary> /// <param name="formid">The formid.</param> /// <param name="fields">The fields.</param> /// <param name="data">The data.</param> public void Execute(ID formid, AdaptedResultList fields, params object[] data) { if (StaticSettings.MasterDatabase == null) { Log.Warn("'Create Item' action : master database is unavailable", this); } NameValueCollection form = new NameValueCollection(); ActionHelper.FillFormData(form, fields, this.ProcessField); // If username and password was given, create a user. if (string.IsNullOrEmpty(form["Email"]) || string.IsNullOrEmpty(form["Password"])) { return; } string name = form["Email"].Trim(); string password = form["Password"]; string email = form["Email"]; string fullNickName = Sitecore.Context.Domain.GetFullName(name); ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >(); CustomerInfo customerInfo = customerManager.CreateCustomerAccount(fullNickName, password, email); if (customerInfo == null) { AnalyticsUtil.AuthentificationAccountCreationFailed(); return; } foreach (string key in form.AllKeys) { customerInfo[key] = form[key]; } customerInfo.BillingAddress.Name = form["Name"]; customerInfo.BillingAddress.Address = form["Address"]; customerInfo.BillingAddress.Zip = form["Zip"]; customerInfo.BillingAddress.City = form["City"]; customerInfo.BillingAddress.State = form["State"]; if (!string.IsNullOrEmpty(form["Country"])) { IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >(); customerInfo.BillingAddress.Country = countryProvider.Get(form["Country"]); } if (form["HideThisSection"] == "1") { customerInfo.ShippingAddress.Name = form["Name"]; customerInfo.ShippingAddress.Address = form["Address"]; customerInfo.ShippingAddress.Zip = form["Zip"]; customerInfo.ShippingAddress.City = form["City"]; customerInfo.ShippingAddress.State = form["State"]; if (!string.IsNullOrEmpty(form["ShippingCountry"])) { IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >(); customerInfo.ShippingAddress.Country = countryProvider.Get(form["ShippingCountry"]); } } else { EntityHelper entityHepler = Context.Entity.Resolve <EntityHelper>(); AddressInfo targetAddressInfo = customerInfo.ShippingAddress; entityHepler.CopyPropertiesValues(customerInfo.BillingAddress, ref targetAddressInfo); } customerManager.UpdateCustomerProfile(customerInfo); customerManager.CurrentUser = customerInfo; AnalyticsUtil.AuthentificationAccountCreated(); }