public virtual IActionResult ExportCsv(NewsletterSubscriptionSearchModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers))
            {
                return(AccessDeniedView());
            }

            bool?isActive = null;

            if (model.ActiveId == 1)
            {
                isActive = true;
            }
            else if (model.ActiveId == 2)
            {
                isActive = false;
            }

            var startDateValue = model.StartDate == null ? null
                : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);
            var endDateValue = model.EndDate == null ? null
                : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            var subscriptions = _newsLetterSubscriptionService.GetAllNewsLetterSubscriptions(model.SearchEmail,
                                                                                             startDateValue, endDateValue, model.StoreId, isActive, model.CustomerRoleId);

            var result = _exportManager.ExportNewsletterSubscribersToTxt(subscriptions);

            var fileName = $"newsletter_emails_{DateTime.Now:yyyy-MM-dd-HH-mm-ss}_{CommonHelper.GenerateRandomDigitCode(4)}.txt";

            return(File(Encoding.UTF8.GetBytes(result), MimeTypes.TextCsv, fileName));
        }
예제 #2
0
        public ActionResult ExportCsv(NewsLetterSubscriptionListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers))
            {
                return(AccessDeniedView());
            }

            bool?isActive = null;

            if (model.ActiveId == 1)
            {
                isActive = true;
            }
            else if (model.ActiveId == 2)
            {
                isActive = false;
            }

            var subscriptions = _newsLetterSubscriptionService.GetAllNewsLetterSubscriptions(model.SearchEmail,
                                                                                             model.StoreId, isActive);

            string result = _exportManager.ExportNewsletterSubscribersToTxt(subscriptions);

            string fileName = String.Format("newsletter_emails_{0}_{1}.txt", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4));

            return(File(Encoding.UTF8.GetBytes(result), "text/csv", fileName));
        }
예제 #3
0
        public async Task <IActionResult> ExportCsv(NewsLetterSubscriptionListModel model, string[] searchCategoryIds)
        {
            bool?isActive = null;

            if (model.ActiveId == 1)
            {
                isActive = true;
            }
            else if (model.ActiveId == 2)
            {
                isActive = false;
            }

            if (_workContext.CurrentCustomer.IsStaff())
            {
                model.StoreId = _workContext.CurrentCustomer.StaffStoreId;
            }

            var subscriptions = await _newsLetterSubscriptionService.GetAllNewsLetterSubscriptions(model.SearchEmail,
                                                                                                   model.StoreId, isActive, searchCategoryIds);

            string result = _exportManager.ExportNewsletterSubscribersToTxt(subscriptions);

            string fileName = String.Format("newsletter_emails_{0}_{1}.txt", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4));

            return(File(Encoding.UTF8.GetBytes(result), "text/csv", fileName));
        }
        public IActionResult ExportCsv(string campaignId)
        {
            try
            {
                var    campaign  = _campaignService.GetCampaignById(campaignId);
                var    customers = _campaignService.CustomerSubscriptions(campaign);
                string result    = _exportManager.ExportNewsletterSubscribersToTxt(customers.Select(x => x.Email).ToList());

                string fileName = String.Format("newsletter_emails_campaign_{0}_{1}.txt", campaign.Name, CommonHelper.GenerateRandomDigitCode(4));
                return(File(Encoding.UTF8.GetBytes(result), "text/csv", fileName));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("List"));
            }
        }
예제 #5
0
        public virtual ActionResult ExportCsv(NewsLetterSubscriptionListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers))
            {
                return(AccessDeniedView());
            }

            bool?isActive = null;

            if (model.ActiveId == 1)
            {
                isActive = true;
            }
            else if (model.ActiveId == 2)
            {
                isActive = false;
            }

            var startDateValue = (model.StartDate == null) ? null
                : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);
            var endDateValue = (model.EndDate == null) ? null
                : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            var subscriptions = _newsLetterSubscriptionService.GetAllNewsLetterSubscriptions(

                createdFromUtc: model.StartDate,
                createdToUtc: model.EndDate,
                storeId: _storeContext.CurrentStore.Id

                );

            string result = _exportManager.ExportNewsletterSubscribersToTxt(subscriptions);

            string fileName = String.Format("newsletter_emails_{0}_{1}.txt", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4));

            return(File(Encoding.UTF8.GetBytes(result), MimeTypes.TextCsv, fileName));
        }
예제 #6
0
 /// <summary>
 /// Export newsletter subscribers to TXT
 /// </summary>
 /// <param name="subscriptions">Subscriptions</param>
 /// <returns>Result in TXT (string) format</returns>
 public string ExportNewsletterSubscribersToTxt(IList <NewsLetterSubscription> subscriptions)
 {
     return(_exportManager.ExportNewsletterSubscribersToTxt(subscriptions));
 }