public static void AuthOrRegCustomer(Customer customer, string identifier) { if (!CustomerService.IsExistOpenIdLinkCustomer(identifier)) { if (!CustomerService.CheckCustomerExist(customer.EMail)) { customer.Id = CustomerService.InsertNewCustomer(customer); var registrationMail = new RegistrationMailTemplate(SettingsMain.SiteUrl, customer.FirstName, customer.LastName, Localization.Culture.ConvertDate(DateTime.Now), customer.Password, customer.SubscribedForNews ? Resources.Resource.Client_Registration_Yes : Resources.Resource.Client_Registration_No, customer.EMail); registrationMail.BuildMail(); SendMail.SendMailNow(SettingsMail.EmailForRegReport, registrationMail.Subject, registrationMail.Body, true); } else { customer = CustomerService.GetCustomerByEmail(customer.EMail); } CustomerService.AddOpenIdLinkCustomer(customer.Id, identifier); customer = CustomerService.GetCustomerByEmail(customer.EMail); } else { customer = CustomerService.GetCustomerByOpenAuthIdentifier(identifier); } AuthorizeService.SignIn(customer.EMail, customer.Password, true, true); }
private void RegistrationNow() { try { if (CustomerService.CheckCustomerExist(PageData.OrderConfirmationData.Customer.EMail)) { ShowMessage(Notify.NotifyType.Error, Resource.Client_Registration_CustomerExist); return; } var id = CustomerService.InsertNewCustomer(new Customer { CustomerGroupId = CustomerGroupService.DefaultCustomerGroup, Password = PageData.OrderConfirmationData.Customer.Password, FirstName = PageData.OrderConfirmationData.Customer.FirstName, LastName = PageData.OrderConfirmationData.Customer.LastName, Phone = PageData.OrderConfirmationData.Customer.Phone, SubscribedForNews = false, EMail = PageData.OrderConfirmationData.Customer.EMail, CustomerRole = Role.User, BonusCardNumber = PageData.OrderConfirmationData.Customer.BonusCardNumber }); if (id == Guid.Empty) { return; } PageData.OrderConfirmationData.Customer.Id = id; AuthorizeService.SignIn(PageData.OrderConfirmationData.Customer.EMail, PageData.OrderConfirmationData.Customer.Password, false, true); var newContact = PageData.OrderConfirmationData.ShippingContact; CustomerService.AddContact(newContact, PageData.OrderConfirmationData.Customer.Id); if (!PageData.OrderConfirmationData.BillingIsShipping) { newContact = PageData.OrderConfirmationData.BillingContact; CustomerService.AddContact(newContact, PageData.OrderConfirmationData.Customer.Id); } var registrationMail = new RegistrationMailTemplate(SettingsMain.SiteUrl, PageData.OrderConfirmationData.Customer.FirstName, PageData.OrderConfirmationData.Customer.LastName, AdvantShop.Localization.Culture.ConvertDate(DateTime.Now), PageData.OrderConfirmationData.Customer.Password, Resource.Client_Registration_No, PageData.OrderConfirmationData.Customer.EMail); registrationMail.BuildMail(); if (CustomerContext.CurrentCustomer.IsVirtual) { ShowMessage(Notify.NotifyType.Notice, Resource.Client_Registration_Whom + PageData.OrderConfirmationData.Customer.EMail + '\r' + Resource.Client_Registration_Text + registrationMail.Body); } else { SendMail.SendMailNow(PageData.OrderConfirmationData.Customer.EMail, registrationMail.Subject, registrationMail.Body, true); SendMail.SendMailNow(SettingsMail.EmailForRegReport, registrationMail.Subject, registrationMail.Body, true); } } catch (Exception ex) { Debug.LogError(ex); } }
protected void btnRegister_Click(object sender, EventArgs e) { if (!DataValidation()) { return; } long?bonusCardNumber = null; var bonusCard = Session["bonuscard"] != null ? Session["bonuscard"].ToString() : null; if (bonusCard.IsNotEmpty()) { var card = BonusSystemService.GetCard(bonusCard.TryParseLong(true)); if (card != null) { bonusCardNumber = card.CardNumber; } Session["bonuscard"] = null; } lblMessage.Visible = false; CustomerService.InsertNewCustomer(new Customer { CustomerGroupId = CustomerGroupService.DefaultCustomerGroup, Password = HttpUtility.HtmlEncode(txtPassword.Text), FirstName = HttpUtility.HtmlEncode(txtFirstName.Text), LastName = SettingsOrderConfirmation.IsShowLastName ? HttpUtility.HtmlEncode(txtLastName.Text) : string.Empty, Patronymic = SettingsOrderConfirmation.IsShowPatronymic ? HttpUtility.HtmlEncode(txtPatronymic.Text) : string.Empty, Phone = SettingsOrderConfirmation.IsShowPhone ? HttpUtility.HtmlEncode(txtPhone.Text) : string.Empty, SubscribedForNews = chkSubscribed4News.Checked, EMail = HttpUtility.HtmlEncode(txtEmail.Text), CustomerRole = Role.User, BonusCardNumber = bonusCardNumber }); AuthorizeService.SignIn(txtEmail.Text, txtPassword.Text, false, true); //------------------------------------------ var regMailTemplate = new RegistrationMailTemplate(SettingsMain.SiteUrl, HttpUtility.HtmlEncode(txtFirstName.Text), HttpUtility.HtmlEncode(txtLastName.Text), AdvantShop.Localization.Culture.ConvertDate(DateTime.Now), HttpUtility.HtmlEncode(txtPassword.Text), chkSubscribed4News.Checked ? Resource.Client_Registration_Yes : Resource.Client_Registration_No, HttpUtility.HtmlEncode(txtEmail.Text)); regMailTemplate.BuildMail(); if (CustomerContext.CurrentCustomer.IsVirtual) { ShowMessage(Notify.NotifyType.Error, Resource.Client_Registration_Whom + txtEmail.Text + '\r' + Resource.Client_Registration_Text + regMailTemplate.Body); } else { SendMail.SendMailNow(txtEmail.Text, regMailTemplate.Subject, regMailTemplate.Body, true); SendMail.SendMailNow(SettingsMail.EmailForRegReport, regMailTemplate.Subject, regMailTemplate.Body, true); } Response.Redirect("myaccount.aspx"); }