Exemple #1
0
        public virtual async Task <CampaignModel> PrepareCampaignModel()
        {
            var model = new CampaignModel();

            model.AllowedTokens = _messageTokenProvider.GetListOfCampaignAllowedTokens();
            //stores
            await PrepareStoresModel(model);

            //languages
            await PrepareLanguagesModel(model);

            //Tags
            await PrepareCustomerTagsModel(model);

            //Roles
            await PrepareCustomerRolesModel(model);

            //Newsletter categories
            await PrepareNewsletterCategoriesModel(model);

            //email
            await PrepareEmailAccounts(model);

            return(model);
        }
Exemple #2
0
        /// <summary>
        /// Prepare campaign model
        /// </summary>
        /// <param name="model">Campaign model</param>
        /// <param name="campaign">Campaign</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Campaign model</returns>
        public virtual CampaignModel PrepareCampaignModel(CampaignModel model, Campaign campaign, bool excludeProperties = false)
        {
            //fill in model values from the entity
            if (campaign != null)
            {
                model = model ?? campaign.ToModel <CampaignModel>();
                if (campaign.DontSendBeforeDateUtc.HasValue)
                {
                    model.DontSendBeforeDate = _dateTimeHelper.ConvertToUserTime(campaign.DontSendBeforeDateUtc.Value, DateTimeKind.Utc);
                }
            }

            model.AllowedTokens = string.Join(", ", _messageTokenProvider.GetListOfCampaignAllowedTokens());

            //whether to fill in some of properties
            if (!excludeProperties)
            {
                model.EmailAccountId = _emailAccountSettings.DefaultEmailAccountId;
            }

            //prepare available stores
            _baseAdminModelFactory.PrepareStores(model.AvailableStores);

            //prepare available customer roles
            _baseAdminModelFactory.PrepareCustomerRoles(model.AvailableCustomerRoles);

            //prepare available email accounts
            _baseAdminModelFactory.PrepareEmailAccounts(model.AvailableEmailAccounts, false);

            return(model);
        }
Exemple #3
0
        public virtual CampaignModel PrepareCampaignModel()
        {
            var model = new CampaignModel();

            model.AllowedTokens = FormatTokens(_messageTokenProvider.GetListOfCampaignAllowedTokens());
            //stores
            PrepareStoresModel(model);
            //Tags
            PrepareCustomerTagsModel(model);
            //Roles
            PrepareCustomerRolesModel(model);
            //Newsletter categories
            PrepareNewsletterCategoriesModel(model);
            //email
            PrepareEmailAccounts(model);
            return(model);
        }
Exemple #4
0
        public ActionResult Create(CampaignModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCampaigns))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var campaign = model.ToEntity();
                campaign.CreatedOnUtc = DateTime.UtcNow;
                _campaignService.InsertCampaign(campaign);

                UpdateLocales(campaign, model);
                SuccessNotification(_localizationService.GetResource("Admin.Promotions.Campaigns.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = campaign.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            model.AllowedTokens = FormatTokens(_messageTokenProvider.GetListOfCampaignAllowedTokens());

            model.CategoriesTree = new List <TreeViewItemModel>();
            model.CategoriesTree = PrepareTreeView(model.CategoriesTree, 0);
            return(View(model));
        }
Exemple #5
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCampaigns))
            {
                return(AccessDeniedView());
            }

            var model = new CampaignModel();

            model.AllowedTokens = FormatTokens(_messageTokenProvider.GetListOfCampaignAllowedTokens());
            return(View(model));
        }
Exemple #6
0
        private void PrepareCampaignModel(CampaignModel model, Campaign campaign, bool excludeProperties)
        {
            model.AvailableStores = _storeService.GetAllStores().Select(s => s.ToModel()).ToList();
            model.AllowedTokens   = string.Join(", ", _messageTokenProvider.GetListOfCampaignAllowedTokens());

            if (!excludeProperties)
            {
                if (campaign != null)
                {
                    model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(campaign);
                }
                else
                {
                    model.SelectedStoreIds = new int[0];
                }
            }

            if (campaign != null)
            {
                model.CreatedOn = _dateTimeHelper.ConvertToUserTime(campaign.CreatedOnUtc, DateTimeKind.Utc);
            }
        }
Exemple #7
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCampaigns))
            {
                return(AccessDeniedView());
            }

            var model = new CampaignModel();

            model.AllowedTokens = FormatTokens(_messageTokenProvider.GetListOfCampaignAllowedTokens());
            //stores
            PrepareStoresModel(model);
            //Tags
            PrepareCustomerTagsModel(model);
            //email
            PrepareEmailAccounts(model);
            return(View(model));
        }
Exemple #8
0
        public virtual ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCampaigns))
            {
                return(AccessDeniedView());
            }

            var model = new CampaignModel();

            model.AllowedTokens = string.Join(", ", _messageTokenProvider.GetListOfCampaignAllowedTokens());
            //stores
            PrepareStoresModel(model);
            //customer roles
            PrepareCustomerRolesModel(model);
            //email accounts
            PrepareEmailAccountsModel(model);
            model.EmailAccountId = _emailAccountSettings.DefaultEmailAccountId;

            return(View(model));
        }