/// <summary> /// Deletes a newsletter subscription /// </summary> /// <param name="newsLetterSubscription">NewsLetter subscription</param> /// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param> public virtual void DeleteNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true) { if (newsLetterSubscription == null) throw new ArgumentNullException("newsLetterSubscription"); _subscriptionRepository.Delete(newsLetterSubscription); //Publish the unsubscribe event PublishSubscriptionEvent(newsLetterSubscription.Email, false, publishSubscriptionEvents); //event notification _eventPublisher.EntityDeleted(newsLetterSubscription); }
public virtual void AddNewsLetterSubscriptionTokens(IList<Token> tokens, NewsLetterSubscription subscription) { tokens.Add(new Token("NewsLetterSubscription.Email", subscription.Email)); const string urlFormat = "{0}newsletter/subscriptionactivation/{1}/{2}"; var activationUrl = String.Format(urlFormat, _webHelper.GetWebLocation(false), subscription.NewsLetterSubscriptionGuid, "true"); tokens.Add(new Token("NewsLetterSubscription.ActivationUrl", activationUrl, true)); var deActivationUrl = String.Format(urlFormat, _webHelper.GetWebLocation(false), subscription.NewsLetterSubscriptionGuid, "false"); tokens.Add(new Token("NewsLetterSubscription.DeactivationUrl", deActivationUrl, true)); }
public JsonResult SubscribeNewsletter(NewsletterBoxModel model) { string result; bool success = false; var email = model.Email; var subscribe = model.Subscribe; if (!CommonHelper.IsValidEmail(email)) { result = _localizationService.GetResource("Newsletter.Email.Wrong"); } else { //subscribe/unsubscribe email = email.Trim(); var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(email); if (subscription != null) { if (subscribe) { if (!subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingCurrency.Id); } result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); } else { if (subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionDeactivationMessage(subscription, _workContext.WorkingLanguage.Id); } result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } } else if (subscribe) { subscription = new NewsLetterSubscription() { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, FirstName = model.FirstName, LastName = model.LastName, Gender = model.Gender, Active = true, CreatedOnUtc = DateTime.UtcNow, LanguageId = _workContext.WorkingLanguage.Id }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); //_workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); //result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); } else { //result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } success = true; } return(Json(new { Success = success })); }
public static NewsLetterSubscriptionModel ToModel(this NewsLetterSubscription entity) { return entity.MapTo<NewsLetterSubscription, NewsLetterSubscriptionModel>(); }
/// <summary> /// Publishes the newsletter unsubscribe event. /// </summary> /// <param name="eventPublisher">The event publisher.</param> /// <param name="subscription">The newsletter subscription.</param> public static void PublishNewsletterUnsubscribe(this IEventPublisher eventPublisher, NewsLetterSubscription subscription) { eventPublisher.Publish(new EmailUnsubscribedEvent(subscription)); }
/// <summary> /// Publishes the newsletter unsubscribe event. /// </summary> /// <param name="eventPublisher">The event publisher.</param> /// <param name="subscription">The newsletter subscription.</param> public static async Task PublishNewsletterUnsubscribeAsync(this IEventPublisher eventPublisher, NewsLetterSubscription subscription) { await eventPublisher.PublishAsync(new EmailUnsubscribedEvent(subscription)); }
public LiquidNewsLetterSubscription(NewsLetterSubscription subscription, Store store) { _subscription = subscription; _store = store; AdditionalTokens = new Dictionary <string, string>(); }
public virtual ActionResult SubscribeNewsletter(string email, bool subscribe) { string result; bool success = false; if (!CommonHelper.IsValidEmail(email)) { result = _localizationService.GetResource("Newsletter.Email.Wrong"); } else { email = email.Trim(); var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreId(email, _storeContext.CurrentStore.Id); if (subscription != null) { if (subscribe) { if (!subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); } result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); } else { if (subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionDeactivationMessage(subscription, _workContext.WorkingLanguage.Id); } result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } } else if (subscribe) { subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, Active = false, StoreId = _storeContext.CurrentStore.Id, CreatedOnUtc = DateTime.UtcNow }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); _workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); } else { result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } success = true; } return(Json(new { Success = success, Result = result, })); }
/// <summary> /// Export customer - personal info to XLSX /// </summary> /// <param name="customer">Customer</param> public virtual async Task <byte[]> ExportCustomerToXlsx(Customer customer, string storeId) { using (var stream = new MemoryStream()) { IWorkbook xlPackage = new XSSFWorkbook(); //customer info ISheet worksheetCustomer = xlPackage.CreateSheet("CustomerInfo"); var managerCustomer = PrepareCustomer(customer); managerCustomer.WriteToXlsx(worksheetCustomer); //address var worksheetAddress = xlPackage.CreateSheet("Address"); var managerAddress = new PropertyManager <Address>(PropertyByAddress()); managerAddress.WriteCaption(worksheetAddress); var row = 1; foreach (var item in customer.Addresses) { managerAddress.CurrentObject = item; managerAddress.WriteToXlsx(worksheetAddress, row++); } //orders var orderService = _serviceProvider.GetRequiredService <IOrderService>(); var orders = await orderService.SearchOrders(customerId : customer.Id); var worksheetOrder = xlPackage.CreateSheet("Orders"); var managerOrder = new PropertyManager <Order>(PropertyByOrder()); managerOrder.WriteCaption(worksheetOrder); row = 1; foreach (var items in orders) { managerOrder.CurrentObject = items; managerOrder.WriteToXlsx(worksheetOrder, row++); } //activity log var customerActivityService = _serviceProvider.GetRequiredService <ICustomerActivityService>(); var actlogs = await customerActivityService.GetAllActivities(customerId : customer.Id); var worksheetLog = xlPackage.CreateSheet("ActivityLogs"); var managerLog = new PropertyManager <ActivityLog>(PropertyByActivityLog()); managerLog.WriteCaption(worksheetLog); row = 1; foreach (var items in actlogs) { managerLog.CurrentObject = items; managerLog.WriteToXlsx(worksheetLog, row++); } //contact us var contactUsService = _serviceProvider.GetRequiredService <IContactUsService>(); var contacts = await contactUsService.GetAllContactUs(customerId : customer.Id); var worksheetContact = xlPackage.CreateSheet("MessageContact"); var managerContact = new PropertyManager <ContactUs>(PropertyByContactForm()); managerContact.WriteCaption(worksheetContact); row = 1; foreach (var items in contacts) { managerContact.CurrentObject = items; managerContact.WriteToXlsx(worksheetContact, row++); } //emails var queuedEmailService = _serviceProvider.GetRequiredService <IQueuedEmailService>(); var queuedEmails = await queuedEmailService.SearchEmails("", customer.Email, null, null, null, false, true, 100, true); var worksheetEmails = xlPackage.CreateSheet("Emails"); var managerEmails = new PropertyManager <QueuedEmail>(PropertyByEmails()); managerEmails.WriteCaption(worksheetEmails); row = 1; foreach (var items in queuedEmails) { managerEmails.CurrentObject = items; managerEmails.WriteToXlsx(worksheetEmails, row++); } //Newsletter subscribe - history of change var newsletterService = _serviceProvider.GetRequiredService <INewsLetterSubscriptionService>(); var newsletter = await newsletterService.GetNewsLetterSubscriptionByEmailAndStoreId(customer.Email, storeId); if (newsletter != null) { var worksheetNewsletter = xlPackage.CreateSheet("Newsletter subscribe - history of change"); var managerNewsletter = new PropertyManager <NewsLetterSubscription>(PropertyByNewsLetterSubscription()); var newsletterhistory = await newsletter.GetHistoryObject(_serviceProvider.GetRequiredService <IHistoryService>()); managerNewsletter.WriteCaption(worksheetNewsletter); row = 1; foreach (var item in newsletterhistory) { var _tmp = (NewsLetterSubscription)item.Object; var newslettertml = new NewsLetterSubscription() { Active = _tmp.Active, CreatedOnUtc = item.CreatedOnUtc }; _tmp.Categories.ToList().ForEach(x => newslettertml.Categories.Add(x)); managerNewsletter.CurrentObject = newslettertml; managerNewsletter.WriteToXlsx(worksheetNewsletter, row++); } } xlPackage.Write(stream); return(stream.ToArray()); } }
/// <summary> /// Inserts a newsletter subscription /// </summary> /// <param name="newsLetterSubscription">NewsLetter subscription</param> /// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param> public void InsertNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true) { _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsLetterSubscription, publishSubscriptionEvents); }
/// <summary> /// Deletes a newsletter subscription /// </summary> /// <param name="newsLetterSubscription">NewsLetter subscription</param> /// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param> public void DeleteNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true) { _newsLetterSubscriptionService.DeleteNewsLetterSubscription(newsLetterSubscription, publishSubscriptionEvents); }
public HttpResponseMessage Subscribe(int customerid, bool subscribe, string email, int id = 0) { var response = this.Request.CreateResponse(); var customer = _customerServices.GetCustomerById(customerid); if (customerid != 0) { _services.WorkContext.CurrentCustomer = customer; } string jsonString = ""; try { string result = ""; var success = false; if (!email.IsEmail()) { result = T("Newsletter.Email.Wrong"); } else { // subscribe/unsubscribe email = email.Trim(); _workContext.CurrentCustomer = (customer != null) ? customer : _customerServices.GetCustomerById(id); var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(email, _storeContext.CurrentStore.Id); if (subscription != null) { if (subscribe) { if (!subscription.Active) { Services.MessageFactory.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); result = T("Newsletter.SubscribeEmailSent"); } else { result = T("Newsletter.AllReadysubscribed"); } } else { if (subscription.Active) { Services.MessageFactory.SendNewsLetterSubscriptionDeactivationMessage(subscription, _workContext.WorkingLanguage.Id); result = T("Newsletter.UnsubscribeEmailSent"); } else { result = T("Newsletter.AllReadyunsubscribed"); } } } else { if (subscribe) { subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, Active = false, CreatedOnUtc = DateTime.UtcNow, StoreId = _storeContext.CurrentStore.Id }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); Services.MessageFactory.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); result = T("Newsletter.SubscribeEmailSent"); } else { result = T("Newsletter.SubscribscribtionNotFound"); } } } jsonString = JsonConvert.SerializeObject(result, Formatting.None); jsonString = "{\"code\":1,\"message\": \"success\",\"data\":" + jsonString + "}"; response.StatusCode = HttpStatusCode.OK; response.Content = new StringContent(jsonString, Encoding.UTF8, "application/json"); return(response); } catch (Exception ex) { jsonString = "{\"code\": 0,\"message\": \"" + _localizationService.GetResource("Common.SomethingWentWrong") + "\"}"; response.Content = new StringContent(jsonString, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage Register(RegisterModel model) { var response = this.Request.CreateResponse(HttpStatusCode.OK); try { string jsonString = ""; var Sponsors = _customerService.GetCustomerByUsername(model.SponsorsName); //check whether registration is allowed if (_customerSettings.UserRegistrationType == UserRegistrationType.Disabled) { //Registrition Disable //(int)UserRegistrationType.Disabled } var customer = _customerService.InsertGuestCustomer(); if (customer.Id != 0) { _workContext.CurrentCustomer = customer; } if (_customerSettings.UsernamesEnabled && model.Username != null) { model.Username = model.Username.Trim(); } customer.AffiliateId = Sponsors.Id; customer.SponsorsName = model.SponsorsName; bool isApproved = _customerSettings.UserRegistrationType == UserRegistrationType.Standard; var registrationRequest = new CustomerRegistrationRequest(customer, model.Email, _customerSettings.UsernamesEnabled ? model.Username : model.Email, model.Password, _customerSettings.DefaultPasswordFormat, isApproved); var registrationResult = _customerRegistrationService.RegisterCustomer(registrationRequest); if (registrationResult.Success) { // properties if (_dateTimeSettings.AllowCustomersToSetTimeZone) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.TimeZoneId, model.TimeZoneId); } // form fields if (_customerSettings.GenderEnabled) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.Gender, model.Gender); } _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.FirstName, model.FirstName); _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.LastName, model.LastName); if (_customerSettings.DateOfBirthEnabled) { DateTime?dateOfBirth = null; try { dateOfBirth = new DateTime(model.DateOfBirthYear.Value, model.DateOfBirthMonth.Value, model.DateOfBirthDay.Value); } catch { } _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.DateOfBirth, dateOfBirth); } if (_customerSettings.CountryEnabled) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.CountryId, model.CountryId); } if (_customerSettings.PhoneEnabled) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.Phone, model.Phone); } if (_customerSettings.CustomerNumberMethod == CustomerNumberMethod.AutomaticallySet && String.IsNullOrEmpty(customer.GetAttribute <string>(SystemCustomerAttributeNames.CustomerNumber))) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.CustomerNumber, customer.Id); } // Notifications if (_customerSettings.NotifyNewCustomerRegistration) { Services.MessageFactory.SendCustomerRegisteredNotificationMessage(customer, _localizationSettings.DefaultAdminLanguageId); } Services.MessageFactory.SendCustomerWelcomeMessage(customer, _workContext.WorkingLanguage.Id); if (_customerSettings.UserRegistrationType == UserRegistrationType.EmailValidation) { // email validation message _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.AccountActivationToken, Guid.NewGuid().ToString()); Services.MessageFactory.SendCustomerEmailValidationMessage(customer, _workContext.WorkingLanguage.Id); var subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = customer.Email, Active = false, CreatedOnUtc = DateTime.UtcNow, StoreId = _storeContext.CurrentStore.Id }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); //return RedirectToRoute("RegisterResult", new { resultId = (int)UserRegistrationType.EmailValidation }); return(Request.CreateResponse(HttpStatusCode.OK, new { code = 1, Message = _localizationService.GetResource("Customer.VerifyEmail") })); } else if (_customerSettings.UserRegistrationType == UserRegistrationType.AdminApproval) { return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = _localizationService.GetResource("Customer.AdminApproval") })); } else { return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "success", GUID = customer.CustomerGuid })); } } else { return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = registrationResult.Errors[0] })); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { code = 1, Message = "Something went wrong, Ex:" + ex.ToString() })); } }
public async Task <SubscribeNewsletterResultModel> Handle(SubscribeNewsletterCommand request, CancellationToken cancellationToken) { var model = new SubscribeNewsletterResultModel(); var email = request.Email; if (!CommonHelper.IsValidEmail(email)) { model.Result = _translationService.GetResource("Newsletter.Email.Wrong"); } else { email = email.Trim(); var subscription = await _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreId(email, _workContext.CurrentStore.Id); if (subscription != null) { if (request.Subscribe) { if (!subscription.Active) { await _messageProviderService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); } model.Result = _translationService.GetResource("Newsletter.SubscribeEmailSent"); } else { if (subscription.Active) { await _messageProviderService.SendNewsLetterSubscriptionDeactivationMessage(subscription, _workContext.WorkingLanguage.Id); } model.Result = _translationService.GetResource("Newsletter.UnsubscribeEmailSent"); } } else if (request.Subscribe) { subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, CustomerId = _workContext.CurrentCustomer.Id, Active = false, StoreId = _workContext.CurrentStore.Id, CreatedOnUtc = DateTime.UtcNow }; await _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); await _messageProviderService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); model.Result = _translationService.GetResource("Newsletter.SubscribeEmailSent"); var modelCategory = await PrepareNewsletterCategory(subscription.Id); if (modelCategory.NewsletterCategories.Count > 0) { model.NewsletterCategory = modelCategory; } } else { model.Result = _translationService.GetResource("Newsletter.UnsubscribeEmailSent"); } model.Success = true; } return(model); }
public virtual async Task <SubscriptionActivationModel> PrepareSubscriptionActivation(NewsLetterSubscription subscription, bool active) { var model = new SubscriptionActivationModel(); if (active) { subscription.Active = true; await _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription); } else { await _newsLetterSubscriptionService.DeleteNewsLetterSubscription(subscription); } model.Result = active ? _localizationService.GetResource("Newsletter.ResultActivated") : _localizationService.GetResource("Newsletter.ResultDeactivated"); return(model); }
public static NewsLetterSubscription ToEntity(this NewsLetterSubscriptionModel model, NewsLetterSubscription entity) { MapperFactory.Map(model, entity); return(entity); }
/// <summary> /// Sends a newsletter subscription deactivation message /// </summary> /// <param name="subscription">Newsletter subscription</param> /// <param name="languageId">Language identifier</param> /// <returns>Queued email identifier</returns> public virtual int SendNewsLetterSubscriptionDeactivationMessage(NewsLetterSubscription subscription, int languageId) { if (subscription == null) throw new ArgumentNullException("subscription"); languageId = EnsureLanguageIsActive(languageId); var messageTemplate = GetLocalizedActiveMessageTemplate("NewsLetterSubscription.DeactivationMessage", languageId); if (messageTemplate == null) return 0; var orderTokens = GenerateTokens(subscription); var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); var toEmail = subscription.Email; var toName = ""; return SendNotification(messageTemplate, emailAccount, languageId, orderTokens, toEmail, toName); }
/// <summary> /// Sends a newsletter subscription deactivation message /// </summary> /// <param name="subscription">Newsletter subscription</param> /// <param name="languageId">Language identifier</param> /// <returns>Queued email identifier</returns> public int SendNewsLetterSubscriptionDeactivationMessage(NewsLetterSubscription subscription, int languageId) { return(_workflowMessageService.SendNewsLetterSubscriptionDeactivationMessage(subscription, languageId)); }
public ActionResult Subscribe(bool subscribe, string email) { string result; var success = false; var customer = Services.WorkContext.CurrentCustomer; var hasConsentedToGdpr = customer.GetAttribute <bool>(SystemCustomerAttributeNames.HasConsentedToGdpr); var hasConsented = ViewData["GdprConsent"] != null ? (bool)ViewData["GdprConsent"] : hasConsentedToGdpr; if (!hasConsented && _privacySettings.Value.DisplayGdprConsentOnForms) { return(Json(new { Success = success, Result = String.Empty })); } if (!email.IsEmail()) { result = T("Newsletter.Email.Wrong"); } else { // subscribe/unsubscribe email = email.Trim(); var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(email, _storeContext.CurrentStore.Id); if (subscription != null) { if (subscribe) { if (!subscription.Active) { Services.MessageFactory.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); } result = T("Newsletter.SubscribeEmailSent"); } else { if (subscription.Active) { Services.MessageFactory.SendNewsLetterSubscriptionDeactivationMessage(subscription, _workContext.WorkingLanguage.Id); } result = T("Newsletter.UnsubscribeEmailSent"); } } else if (subscribe) { subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, Active = false, CreatedOnUtc = DateTime.UtcNow, StoreId = _storeContext.CurrentStore.Id, WorkingLanguageId = _workContext.WorkingLanguage.Id }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); Services.MessageFactory.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); result = T("Newsletter.SubscribeEmailSent"); } else { result = T("Newsletter.UnsubscribeEmailSent"); } success = true; } return(Json(new { Success = success, Result = result, })); }
public ImportResult ImportSubscribers(Stream stream) { Guard.ArgumentNotNull(() => stream); var result = new ImportResult(); var toAdd = new List <NewsLetterSubscription>(); var toUpdate = new List <NewsLetterSubscription>(); var autoCommit = _subscriptionRepository.AutoCommitEnabled; var validateOnSave = _subscriptionRepository.Context.ValidateOnSaveEnabled; var autoDetectChanges = _subscriptionRepository.Context.AutoDetectChangesEnabled; var proxyCreation = _subscriptionRepository.Context.ProxyCreationEnabled; try { using (var reader = new StreamReader(stream)) { _subscriptionRepository.Context.ValidateOnSaveEnabled = false; _subscriptionRepository.Context.AutoDetectChangesEnabled = false; _subscriptionRepository.Context.ProxyCreationEnabled = false; while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line.IsEmpty()) { continue; } string[] tmp = line.Split(','); var email = ""; bool isActive = true; // parse if (tmp.Length == 1) { // "email" only email = tmp[0].Trim(); } else if (tmp.Length == 2) { // "email" and "active" fields specified email = tmp[0].Trim(); isActive = Boolean.Parse(tmp[1].Trim()); } else { throw new InSearchException("Wrong file format (expected comma separated entries 'Email' and optionally 'IsActive')"); } result.TotalRecords++; if (email.Length > 255) { result.AddWarning("The email address '{0}' exceeds the maximum allowed length of 255.".FormatInvariant(email)); continue; } if (!email.IsEmail()) { result.AddWarning("'{0}' is not a valid email address.".FormatInvariant(email)); continue; } // import var subscription = (from nls in _subscriptionRepository.Table where nls.Email == email orderby nls.Id select nls).FirstOrDefault(); if (subscription != null) { subscription.Active = isActive; toUpdate.Add(subscription); result.ModifiedRecords++; } else { subscription = new NewsLetterSubscription() { Active = isActive, CreatedOnUtc = DateTime.UtcNow, Email = email, NewsLetterSubscriptionGuid = Guid.NewGuid() }; toAdd.Add(subscription); result.NewRecords++; } } } // insert new subscribers _subscriptionRepository.AutoCommitEnabled = true; _subscriptionRepository.InsertRange(toAdd, 500); toAdd.Clear(); // update modified subscribers _subscriptionRepository.AutoCommitEnabled = false; toUpdate.Each(x => { _subscriptionRepository.Update(x); }); _subscriptionRepository.Context.SaveChanges(); toUpdate.Clear(); } catch (Exception ex) { throw ex; } finally { _subscriptionRepository.AutoCommitEnabled = autoCommit; _subscriptionRepository.Context.ValidateOnSaveEnabled = validateOnSave; _subscriptionRepository.Context.AutoDetectChangesEnabled = autoDetectChanges; _subscriptionRepository.Context.ProxyCreationEnabled = proxyCreation; } return(result); }
public ActionResult ImportCsv(FormCollection form) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers)) { return(AccessDeniedView()); } try { var file = Request.Files["importcsvfile"]; if (file != null && file.ContentLength > 0) { int count = 0; using (var reader = new StreamReader(file.InputStream)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (String.IsNullOrWhiteSpace(line)) { continue; } string[] tmp = line.Split(','); var email = ""; bool isActive = true; //parse if (tmp.Length == 1) { //"email" only email = tmp[0].Trim(); } else if (tmp.Length == 2) { //"email" and "active" fields specified email = tmp[0].Trim(); isActive = Boolean.Parse(tmp[1].Trim()); } else { throw new NasException("Wrong file format"); } //import var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(email); if (subscription != null) { subscription.Email = email; subscription.Active = isActive; _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription); } else { subscription = new NewsLetterSubscription() { Active = isActive, CreatedOnUtc = DateTime.UtcNow, Email = email, NewsLetterSubscriptionGuid = Guid.NewGuid() }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); } count++; } SuccessNotification(String.Format(_localizationService.GetResource("Admin.Promotions.NewsLetterSubscriptions.ImportEmailsSuccess"), count)); return(RedirectToAction("List")); } } ErrorNotification(_localizationService.GetResource("Admin.Common.UploadFile")); return(RedirectToAction("List")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
/// <summary> /// Sends a newsletter subscription deactivation message /// </summary> public static CreateMessageResult SendNewsLetterSubscriptionDeactivationMessage(this IMessageFactory factory, NewsLetterSubscription subscription, int languageId = 0) { Guard.NotNull(subscription, nameof(subscription)); return(factory.CreateMessage(MessageContext.Create(MessageTemplateNames.NewsLetterSubscriptionDeactivation, languageId), true, subscription)); }
public virtual SubscribeNewsletterResultModel SubscribeNewsletter(string email, bool subscribe) { var model = new SubscribeNewsletterResultModel(); if (!CommonHelper.IsValidEmail(email)) { model.Result = _localizationService.GetResource("Newsletter.Email.Wrong"); } else { email = email.Trim(); var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreId(email, _storeContext.CurrentStore.Id); if (subscription != null) { if (subscribe) { if (!subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); } model.Result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); } else { if (subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionDeactivationMessage(subscription, _workContext.WorkingLanguage.Id); } model.Result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } } else if (subscribe) { subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, CustomerId = _workContext.CurrentCustomer.Id, Active = false, StoreId = _storeContext.CurrentStore.Id, CreatedOnUtc = DateTime.UtcNow }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); _workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); model.Result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); var modelCategory = PrepareNewsletterCategory(subscription.Id); if (modelCategory.NewsletterCategories.Count > 0) { model.NewsletterCategory = modelCategory; } } else { model.Result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } model.Success = true; } return(model); }
/// <summary> /// Inserts a newsletter subscription /// </summary> /// <param name="newsLetterSubscription">NewsLetter subscription</param> /// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param> public virtual void InsertNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true) { if (newsLetterSubscription == null) { throw new ArgumentNullException("newsLetterSubscription"); } //Handle e-mail newsLetterSubscription.Email = CommonHelper.EnsureSubscriberEmailOrThrow(newsLetterSubscription.Email); //Persist _subscriptionRepository.Insert(newsLetterSubscription); //Publish the subscription event if (newsLetterSubscription.Active) { PublishSubscriptionEvent(newsLetterSubscription.Email, true, publishSubscriptionEvents); } //Publish event _eventPublisher.EntityInserted(newsLetterSubscription); }
public void Execute(IImportExecuteContext context) { var utcNow = DateTime.UtcNow; var currentStoreId = _services.StoreContext.CurrentStore.Id; var toAdd = new List <NewsLetterSubscription>(); var toUpdate = new List <NewsLetterSubscription>(); using (var scope = new DbContextScope(ctx: _services.DbContext, autoDetectChanges: false, proxyCreation: false, validateOnSave: false, autoCommit: false)) { var segmenter = context.GetSegmenter <NewsLetterSubscription>(); context.Result.TotalRecords = segmenter.TotalRows; while (context.Abort == DataExchangeAbortion.None && segmenter.ReadNextBatch()) { var batch = segmenter.CurrentBatch; _subscriptionRepository.Context.DetachAll(false); context.SetProgress(segmenter.CurrentSegmentFirstRowIndex - 1, segmenter.TotalRows); foreach (var row in batch) { try { var email = row.GetDataValue <string>("Email"); var active = row.GetDataValue <bool>("Active"); var storeId = row.GetDataValue <int>("StoreId"); if (storeId == 0) { storeId = currentStoreId; } if (email.IsEmpty()) { context.Result.AddWarning("Skipped empty email address", row.GetRowInfo(), "Email"); continue; } if (email.Length > 255) { context.Result.AddWarning("Skipped email address '{0}'. It exceeds the maximum allowed length of 255".FormatInvariant(email), row.GetRowInfo(), "Email"); continue; } if (!email.IsEmail()) { context.Result.AddWarning("Skipped invalid email address '{0}'".FormatInvariant(email), row.GetRowInfo(), "Email"); continue; } NewsLetterSubscription subscription = null; foreach (var keyName in context.KeyFieldNames) { switch (keyName) { case "Email": subscription = _subscriptionRepository.Table .OrderBy(x => x.Id) .FirstOrDefault(x => x.Email == email && x.StoreId == storeId); break; } if (subscription != null) { break; } } if (subscription == null) { if (context.UpdateOnly) { ++context.Result.SkippedRecords; continue; } subscription = new NewsLetterSubscription { Active = active, CreatedOnUtc = utcNow, Email = email, NewsLetterSubscriptionGuid = Guid.NewGuid(), StoreId = storeId }; toAdd.Add(subscription); ++context.Result.NewRecords; } else { subscription.Active = active; toUpdate.Add(subscription); ++context.Result.ModifiedRecords; } // insert new subscribers _subscriptionRepository.AutoCommitEnabled = true; _subscriptionRepository.InsertRange(toAdd, 500); toAdd.Clear(); // update modified subscribers _subscriptionRepository.UpdateRange(toUpdate); toUpdate.Clear(); } catch (Exception exception) { context.Result.AddError(exception.ToAllMessages(), row.GetRowInfo()); } } } } }
/// <summary> /// Updates a newsletter subscription /// </summary> /// <param name="newsLetterSubscription">NewsLetter subscription</param> /// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param> public virtual void UpdateNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true) { if (newsLetterSubscription == null) { throw new ArgumentNullException("newsLetterSubscription"); } //Handle e-mail newsLetterSubscription.Email = CommonHelper.EnsureSubscriberEmailOrThrow(newsLetterSubscription.Email); //Get original subscription record var originalSubscription = _context.LoadOriginalCopy(newsLetterSubscription); //Persist _subscriptionRepository.Update(newsLetterSubscription); //Publish the subscription event if ((originalSubscription.Active == false && newsLetterSubscription.Active) || (newsLetterSubscription.Active && (originalSubscription.Email != newsLetterSubscription.Email))) { //If the previous entry was false, but this one is true, publish a subscribe. PublishSubscriptionEvent(newsLetterSubscription.Email, true, publishSubscriptionEvents); } if ((originalSubscription.Active && newsLetterSubscription.Active) && (originalSubscription.Email != newsLetterSubscription.Email)) { //If the two emails are different publish an unsubscribe. PublishSubscriptionEvent(originalSubscription.Email, false, publishSubscriptionEvents); } if ((originalSubscription.Active && !newsLetterSubscription.Active)) { //If the previous entry was true, but this one is false PublishSubscriptionEvent(originalSubscription.Email, false, publishSubscriptionEvents); } //Publish event _eventPublisher.EntityUpdated(newsLetterSubscription); }
public ActionResult Subscribe(bool subscribe, string email) { string result; bool success = false; if (!email.IsEmail()) { result = _localizationService.GetResource("Newsletter.Email.Wrong"); } else { //subscribe/unsubscribe email = email.Trim(); var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(email, _siteContext.CurrentSite.Id); if (subscription != null) { if (subscribe) { if (!subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); } result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); } else { if (subscription.Active) { _workflowMessageService.SendNewsLetterSubscriptionDeactivationMessage(subscription, _workContext.WorkingLanguage.Id); } result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } } else if (subscribe) { subscription = new NewsLetterSubscription() { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, Active = false, CreatedOnUtc = DateTime.UtcNow, SiteId = _siteContext.CurrentSite.Id }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); _workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id); result = _localizationService.GetResource("Newsletter.SubscribeEmailSent"); } else { result = _localizationService.GetResource("Newsletter.UnsubscribeEmailSent"); } success = true; } return(Json(new { Success = success, Result = result, })); }
public static NewsLetterSubscription ToEntity(this NewsLetterSubscriptionModel model, NewsLetterSubscription destination) { return(Mapper.Map(model, destination)); }
public static NewsLetterSubscription ToEntity(this NewsLetterSubscriptionModel model, NewsLetterSubscription destination) { return model.MapTo(destination); }
/// <summary> /// Import newsletter subscribers from TXT file /// </summary> /// <param name="stream">Stream</param> /// <returns>Number of imported subscribers</returns> public virtual int ImportNewsletterSubscribersFromTxt(Stream stream) { int count = 0; using (var reader = new StreamReader(stream)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (String.IsNullOrWhiteSpace(line)) { continue; } string[] tmp = line.Split(','); string email; bool isActive = true; int storeId = _storeContext.CurrentStore.Id; //parse if (tmp.Length == 1) { //"email" only email = tmp[0].Trim(); } else if (tmp.Length == 2) { //"email" and "active" fields specified email = tmp[0].Trim(); isActive = Boolean.Parse(tmp[1].Trim()); } else if (tmp.Length == 3) { //"email" and "active" and "storeId" fields specified email = tmp[0].Trim(); isActive = Boolean.Parse(tmp[1].Trim()); storeId = Int32.Parse(tmp[2].Trim()); } else { throw new NopException("Wrong file format"); } //import var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreId(email, storeId); if (subscription != null) { subscription.Email = email; subscription.Active = isActive; _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription); } else { subscription = new NewsLetterSubscription { Active = isActive, CreatedOnUtc = DateTime.UtcNow, Email = email, StoreId = storeId, NewsLetterSubscriptionGuid = Guid.NewGuid() }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); } count++; } } return(count); }
public static NewsLetterSubscriptionModel ToModel(this NewsLetterSubscription entity) { return(Mapper.Map <NewsLetterSubscription, NewsLetterSubscriptionModel>(entity)); }
private IList<Token> GenerateTokens(NewsLetterSubscription subscription) { var tokens = new List<Token>(); _messageTokenProvider.AddWebTokens(tokens); _messageTokenProvider.AddNewsLetterSubscriptionTokens(tokens, subscription); return tokens; }
public static NewsLetterSubscriptionDto ToDto(this NewsLetterSubscription newsLetterSubscription) { return(newsLetterSubscription.MapTo <NewsLetterSubscription, NewsLetterSubscriptionDto>()); }
public virtual async Task <IActionResult> SubscribeNewsletter(string email, bool subscribe) { string result; var success = false; if (!CommonHelper.IsValidEmail(email)) { result = await _localizationService.GetResourceAsync("Newsletter.Email.Wrong"); } else { email = email.Trim(); var subscription = await _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreIdAsync(email, (await _storeContext.GetCurrentStoreAsync()).Id); if (subscription != null) { if (subscribe) { if (!subscription.Active) { await _workflowMessageService.SendNewsLetterSubscriptionActivationMessageAsync( subscription, (await _workContext.GetWorkingLanguageAsync()).Id ); } result = await _localizationService.GetResourceAsync("Newsletter.SubscribeEmailSent"); } else { if (subscription.Active) { await _workflowMessageService.SendNewsLetterSubscriptionDeactivationMessageAsync( subscription, (await _workContext.GetWorkingLanguageAsync()).Id ); } result = await _localizationService.GetResourceAsync("Newsletter.UnsubscribeEmailSent"); } } else if (subscribe) { try { var freshAddressResponse = await _freshAddressService.ValidateEmailAsync(email); if (!freshAddressResponse.IsValid) { return(Json(new { Success = false, Result = freshAddressResponse.ErrorResponse, })); } } catch (Exception ex) { await _logger.ErrorAsync($"An error occured while trying to validate a Newsletter signup through FreshAddress: {ex}"); } subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, Active = false, StoreId = (await _storeContext.GetCurrentStoreAsync()).Id, CreatedOnUtc = DateTime.UtcNow }; await _newsLetterSubscriptionService.InsertNewsLetterSubscriptionAsync(subscription); await _workflowMessageService.SendNewsLetterSubscriptionActivationMessageAsync(subscription, (_workContext.GetWorkingLanguageAsync()).Id); result = await _localizationService.GetResourceAsync("Newsletter.SubscribeEmailSent"); } else { result = await _localizationService.GetResourceAsync("Newsletter.UnsubscribeEmailSent"); } success = true; } return(Json(new { Success = success, Result = result, })); }
/// <summary> /// Ctor /// </summary> /// <param name="subscription">Subscription</param> public EmailSubscribedEvent(NewsLetterSubscription subscription) { Subscription = subscription; }
public async Task <bool> Handle(CustomerRegisteredCommand request, CancellationToken cancellationToken) { //properties if (_dateTimeSettings.AllowCustomersToSetTimeZone) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.TimeZoneId, request.Model.TimeZoneId); } //VAT number if (_taxSettings.EuVatEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.VatNumber, request.Model.VatNumber); var vat = await _taxService.GetVatNumberStatus(request.Model.VatNumber); await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.VatNumberStatusId, (int)vat.status); //send VAT number admin notification if (!String.IsNullOrEmpty(request.Model.VatNumber) && _taxSettings.EuVatEmailAdminWhenNewVatSubmitted) { await _workflowMessageService.SendNewVatSubmittedStoreOwnerNotification(request.Customer, request.Store, request.Model.VatNumber, vat.address, _localizationSettings.DefaultAdminLanguageId); } } //form fields if (_customerSettings.GenderEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.Gender, request.Model.Gender); } await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.FirstName, request.Model.FirstName); await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.LastName, request.Model.LastName); if (_customerSettings.DateOfBirthEnabled) { DateTime?dateOfBirth = request.Model.ParseDateOfBirth(); await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.DateOfBirth, dateOfBirth); } if (_customerSettings.CompanyEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.Company, request.Model.Company); } if (_customerSettings.StreetAddressEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.StreetAddress, request.Model.StreetAddress); } if (_customerSettings.StreetAddress2Enabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.StreetAddress2, request.Model.StreetAddress2); } if (_customerSettings.ZipPostalCodeEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.ZipPostalCode, request.Model.ZipPostalCode); } if (_customerSettings.CityEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.City, request.Model.City); } if (_customerSettings.CountryEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.CountryId, request.Model.CountryId); } if (_customerSettings.CountryEnabled && _customerSettings.StateProvinceEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.StateProvinceId, request.Model.StateProvinceId); } if (_customerSettings.PhoneEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.Phone, request.Model.Phone); } if (_customerSettings.FaxEnabled) { await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.Fax, request.Model.Fax); } //newsletter if (_customerSettings.NewsletterEnabled) { var categories = new List <string>(); foreach (string formKey in request.Form.Keys) { if (formKey.Contains("customernewsletterCategory_")) { try { var category = formKey.Split('_')[1]; categories.Add(category); } catch { } } } //save newsletter value var newsletter = await _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreId(request.Model.Email, request.Store.Id); if (newsletter != null) { newsletter.Categories.Clear(); categories.ForEach(x => newsletter.Categories.Add(x)); if (request.Model.Newsletter) { newsletter.Active = true; await _newsLetterSubscriptionService.UpdateNewsLetterSubscription(newsletter); } } else { if (request.Model.Newsletter) { var newsLetterSubscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = request.Model.Email, CustomerId = request.Customer.Id, Active = true, StoreId = request.Store.Id, CreatedOnUtc = DateTime.UtcNow }; categories.ForEach(x => newsLetterSubscription.Categories.Add(x)); await _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsLetterSubscription); } } } //save customer attributes await _genericAttributeService.SaveAttribute(request.Customer, SystemCustomerAttributeNames.CustomCustomerAttributes, request.CustomerAttributesXml); //insert default address (if possible) var defaultAddress = new Address { FirstName = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.FirstName), LastName = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.LastName), Email = request.Customer.Email, Company = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.Company), VatNumber = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.VatNumber), CountryId = !string.IsNullOrEmpty(request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.CountryId)) ? request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.CountryId) : "", StateProvinceId = !string.IsNullOrEmpty(request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.StateProvinceId)) ? request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.StateProvinceId) : "", City = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.City), Address1 = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.StreetAddress), Address2 = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.StreetAddress2), ZipPostalCode = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.ZipPostalCode), PhoneNumber = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.Phone), FaxNumber = request.Customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.Fax), CreatedOnUtc = request.Customer.CreatedOnUtc, }; if (await _addressService.IsAddressValid(defaultAddress)) { //set default address defaultAddress.CustomerId = request.Customer.Id; request.Customer.Addresses.Add(defaultAddress); await _customerService.InsertAddress(defaultAddress); request.Customer.BillingAddress = defaultAddress; await _customerService.UpdateBillingAddress(defaultAddress); request.Customer.ShippingAddress = defaultAddress; await _customerService.UpdateShippingAddress(defaultAddress); } //notifications if (_customerSettings.NotifyNewCustomerRegistration) { await _workflowMessageService.SendCustomerRegisteredNotificationMessage(request.Customer, request.Store, _localizationSettings.DefaultAdminLanguageId); } //New customer has a free shipping for the first order if (_customerSettings.RegistrationFreeShipping) { await _customerService.UpdateFreeShipping(request.Customer.Id, true); } await _customerActionEventService.Registration(request.Customer); return(true); }