public ActionResult SubscriptionUpdate(NewsLetterSubscriptionModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                //display the first model error
                var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return(Content(modelStateErrors.FirstOrDefault()));
            }

            var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(model.Id);

            subscription.Email  = model.Email;
            subscription.Active = model.Active;

            _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription);

            var listModel = new NewsLetterSubscriptionListModel();

            PrepareNewsLetterSubscriptionListModel(listModel);

            return(SubscriptionList(command, listModel));
        }
        public ActionResult SubscriptionUpdate(NewsLetterSubscriptionModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers))
            {
                return(AccessDeniedView());
            }

            var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(model.Id);

            subscription.Email  = model.Email;
            subscription.Active = model.Active;
            _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription);

            return(SubscriptionList(command, new NewsLetterSubscriptionListModel()));
        }
        public async Task <IActionResult> SubscriptionUpdate(NewsLetterSubscriptionModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var subscription = await _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(model.Id);

            subscription.Email  = model.Email;
            subscription.Active = model.Active;
            await _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription);

            return(new NullJsonResult());
        }
示例#4
0
        public virtual IActionResult SubscriptionUpdate(NewsletterSubscriptionModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(ErrorJson(ModelState.SerializeErrors()));
            }

            var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(model.Id);

            //fill entity from model
            subscription = model.ToEntity(subscription);
            _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription);

            return(new NullJsonResult());
        }
        public ActionResult SubscriptionUpdate(NewsLetterSubscriptionModel model, GridCommand command)
        {
            if (!ModelState.IsValid)
            {
                var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return(Content(modelStateErrors.FirstOrDefault()));
            }

            var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(model.Id);

            subscription.Email  = model.Email;
            subscription.Active = model.Active;

            _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription);

            var listModel = new NewsLetterSubscriptionListModel();

            PrepareNewsLetterSubscriptionListModel(listModel);

            return(SubscriptionList(command, listModel));
        }
        public virtual IActionResult SubscriptionUpdate(NewsletterSubscriptionModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(model.Id);

            subscription.Email  = model.Email;
            subscription.Active = model.Active;
            _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription);

            return(new NullJsonResult());
        }
        public virtual async Task <IActionResult> SaveCategories(IFormCollection form)
        {
            bool   success = false;
            string message = string.Empty;

            var newsletterEmailId = form["NewsletterEmailId"].ToString();

            if (!string.IsNullOrEmpty(newsletterEmailId))
            {
                var subscription = await _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(newsletterEmailId);

                if (subscription != null)
                {
                    foreach (string formKey in form.Keys)
                    {
                        if (formKey.Contains("Category_"))
                        {
                            try
                            {
                                var category = formKey.Split('_')[1];
                                subscription.Categories.Add(category);
                            }
                            catch (Exception ex)
                            {
                                message = ex.Message;
                            }
                        }
                    }
                    success = true;
                    await _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription, false);
                }
                else
                {
                    message = "Email not exist";
                }
            }
            else
            {
                message = "Empty NewsletterEmailId";
            }

            return(Json(new
            {
                Success = success,
                Message = message
            }));
        }
示例#8
0
 /// <summary>
 /// Gets a newsletter subscription by newsletter subscription identifier
 /// </summary>
 /// <param name="newsLetterSubscriptionId">The newsletter subscription identifier</param>
 /// <returns>NewsLetter subscription</returns>
 public NewsLetterSubscription GetNewsLetterSubscriptionById(int newsLetterSubscriptionId)
 {
     return(_newsLetterSubscriptionService.GetNewsLetterSubscriptionById(newsLetterSubscriptionId));
 }
示例#9
0
        public ActionResult CampaignFriendsConvoke(NewsletterBoxModel model)  // Davet edilen maillerin kaydı
        {
            string Id = RouteData.Values["id"].ToString();

            if (Id == null)
            {
                RedirectToAction("Index");
            }

            var referermodel = _newsLetterSubscriptionService.GetNewsLetterSubscriptionById(int.Parse(Id));

            if (model.Email1 != null)
            {
                var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(model.Email1);
                if (subscription == null)
                {
                    NewsLetterSubscription newsletterModel = new NewsLetterSubscription();
                    newsletterModel.Email                      = model.Email1;
                    newsletterModel.CreatedOnUtc               = DateTime.Now;
                    newsletterModel.RegistrationType           = "Campaign";
                    newsletterModel.NewsLetterSubscriptionGuid = Guid.NewGuid();
                    if (referermodel != null)
                    {
                        newsletterModel.RefererEmail = referermodel.Email;
                    }
                    _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsletterModel);
                    _workflowMessageService.SendCampaignConvoke(newsletterModel, _workContext.WorkingLanguage.Id);
                }
            }

            if (model.Email2 != null)
            {
                var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(model.Email2);
                if (subscription == null)
                {
                    NewsLetterSubscription newsletterModel = new NewsLetterSubscription();
                    newsletterModel.Email                      = model.Email2;
                    newsletterModel.CreatedOnUtc               = DateTime.Now;
                    newsletterModel.RegistrationType           = "Campaign";
                    newsletterModel.NewsLetterSubscriptionGuid = Guid.NewGuid();
                    if (referermodel != null)
                    {
                        newsletterModel.RefererEmail = referermodel.Email;
                    }
                    _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsletterModel);
                    _workflowMessageService.SendCampaignConvoke(newsletterModel, _workContext.WorkingLanguage.Id);
                }
            }

            if (model.Email3 != null)
            {
                var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(model.Email3);
                if (subscription == null)
                {
                    NewsLetterSubscription newsletterModel = new NewsLetterSubscription();
                    newsletterModel.Email                      = model.Email3;
                    newsletterModel.CreatedOnUtc               = DateTime.Now;
                    newsletterModel.RegistrationType           = "Campaign";
                    newsletterModel.NewsLetterSubscriptionGuid = Guid.NewGuid();
                    if (referermodel != null)
                    {
                        newsletterModel.RefererEmail = referermodel.Email;
                    }
                    _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsletterModel);
                    _workflowMessageService.SendCampaignConvoke(newsletterModel, _workContext.WorkingLanguage.Id);
                }
            }

            if (model.Email4 != null)
            {
                var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(model.Email4);
                if (subscription == null)
                {
                    NewsLetterSubscription newsletterModel = new NewsLetterSubscription();
                    newsletterModel.Email                      = model.Email4;
                    newsletterModel.CreatedOnUtc               = DateTime.Now;
                    newsletterModel.RegistrationType           = "Campaign";
                    newsletterModel.NewsLetterSubscriptionGuid = Guid.NewGuid();
                    if (referermodel != null)
                    {
                        newsletterModel.RefererEmail = referermodel.Email;
                    }
                    _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsletterModel);
                    _workflowMessageService.SendCampaignConvoke(newsletterModel, _workContext.WorkingLanguage.Id);
                }
            }

            if (model.Email5 != null)
            {
                var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmail(model.Email5);
                if (subscription == null)
                {
                    NewsLetterSubscription newsletterModel = new NewsLetterSubscription();
                    newsletterModel.Email                      = model.Email5;
                    newsletterModel.CreatedOnUtc               = DateTime.Now;
                    newsletterModel.RegistrationType           = "Campaign";
                    newsletterModel.NewsLetterSubscriptionGuid = Guid.NewGuid();
                    if (referermodel != null)
                    {
                        newsletterModel.RefererEmail = referermodel.Email;
                    }
                    _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsletterModel);
                    _workflowMessageService.SendCampaignConvoke(newsletterModel, _workContext.WorkingLanguage.Id);
                }
            }

            return(RedirectToRoute("CampaignRecordSuccessFul"));      //("CampaignRecordSuccessFul","Home");
        }