本文整理汇总了C#中Nop.Core.Domain.Messages.NewsLetterSubscription类的典型用法代码示例。如果您正苦于以下问题:C# NewsLetterSubscription类的具体用法?C# NewsLetterSubscription怎么用?C# NewsLetterSubscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NewsLetterSubscription类属于Nop.Core.Domain.Messages命名空间,在下文中一共展示了NewsLetterSubscription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewEntry
public ActionResult NewEntry([Bind(Include="CustomerName,CustomerEmail,ProductId")]TrialTrackerRecord vm)
{
if (ModelState.IsValid)
{
var product = _productService.GetProductById(vm.ProductId);
vm.ProductName = product.Name;
vm.DownloadDate = DateTime.Now.ToString("MM/dd/yyyy");
// check if they should be auto added to mailing list
if (_settings.GetSettingByKey<bool>("AutoAddTrialEmail"))
{
vm.OnMailingList = true;
NewsLetterSubscription subscriber = new NewsLetterSubscription
{
Active = true,
CreatedOnUtc = DateTime.Now,
Email = vm.CustomerEmail
};
_mailingService.InsertNewsLetterSubscription(subscriber);
}
else
{
vm.OnMailingList = false;
}
_trialRepo.Insert(vm);
return View("_DownloadLink", vm);
}
else
{
return View();
}
}
示例2: VerifyDeleteTriggersUnsubscribeEvent
public void VerifyDeleteTriggersUnsubscribeEvent()
{
var service = new NewsLetterSubscriptionService(_dbContext, _newsLetterSubscriptionRepository,
_customerRepository, _eventPublisher, _customerService);
var subscription = new NewsLetterSubscription { Active = true, Email = "[email protected]" };
service.DeleteNewsLetterSubscription(subscription, true);
_eventPublisher.AssertWasCalled(x => x.Publish(new EmailUnsubscribedEvent(subscription.Email)));
}
示例3: DeleteNewsLetterSubscription
/// <summary>
/// Deletes a newsletter subscription
/// </summary>
/// <param name="newsLetterSubscription">NewsLetter subscription</param>
public virtual void DeleteNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription)
{
if (newsLetterSubscription == null)
throw new ArgumentNullException("newsLetterSubscription");
_newsLetterSubscriptionRepository.Delete(newsLetterSubscription);
//event notification
_eventPublisher.EntityDeleted(newsLetterSubscription);
}
示例4: DeleteNewsLetterSubscription
/// <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);
}
示例5: VerifyDeleteTriggersUnsubscribeEvent
public void VerifyDeleteTriggersUnsubscribeEvent()
{
var eventPublisher = MockRepository.GenerateStub<IEventPublisher>();
var repo = MockRepository.GenerateStub<IRepository<NewsLetterSubscription>>();
var context = MockRepository.GenerateStub<IDbContext>();
var subscription = new NewsLetterSubscription { Active = true, Email = "[email protected]" };
var service = new NewsLetterSubscriptionService(context, repo, eventPublisher);
service.DeleteNewsLetterSubscription(subscription, true);
eventPublisher.AssertWasCalled(x => x.Publish(new EmailUnsubscribedEvent(subscription.Email)));
}
示例6: VerifyEmailUpdateTriggersUnsubscribeAndSubscribeEvent
public void VerifyEmailUpdateTriggersUnsubscribeAndSubscribeEvent()
{
//Prepare the original result
var originalSubscription = new NewsLetterSubscription { Active = true, Email = "[email protected]" };
_newsLetterSubscriptionRepository.Stub(m => m.GetById(Arg<object>.Is.Anything)).Return(originalSubscription);
var service = new NewsLetterSubscriptionService(_dbContext, _newsLetterSubscriptionRepository,
_customerRepository, _eventPublisher, _customerService);
var subscription = new NewsLetterSubscription { Active = true, Email = "[email protected]" };
service.UpdateNewsLetterSubscription(subscription, true);
_eventPublisher.AssertWasCalled(x => x.Publish(new EmailUnsubscribedEvent(originalSubscription.Email)));
_eventPublisher.AssertWasCalled(x => x.Publish(new EmailSubscribedEvent(subscription.Email)));
}
示例7: VerifyInactiveToActiveUpdateTriggersSubscribeEvent
public void VerifyInactiveToActiveUpdateTriggersSubscribeEvent()
{
var eventPublisher = MockRepository.GenerateStub<IEventPublisher>();
var repo = MockRepository.GenerateStub<IRepository<NewsLetterSubscription>>();
var context = MockRepository.GenerateStub<IDbContext>();
//Prepare the original result
var originalSubscription = new NewsLetterSubscription { Active = false, Email = "[email protected]" };
repo.Stub(m => m.GetById(Arg<object>.Is.Anything)).Return(originalSubscription);
var subscription = new NewsLetterSubscription { Active = true, Email = "[email protected]" };
var service = new NewsLetterSubscriptionService(context, repo, eventPublisher);
service.UpdateNewsLetterSubscription(subscription, true);
eventPublisher.AssertWasCalled(x => x.Publish(new EmailSubscribedEvent(subscription.Email)));
}
示例8: SubscribeNewsletter
public ActionResult SubscribeNewsletter(string email)
{
string result;
bool success = false;
if (!CommonHelper.IsValidEmail(email))
result = _localizationService.GetResource("Newsletter.Email.Wrong");
else
{
//subscribe/unsubscribe
email = email.Trim();
var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreId(email, _storeContext.CurrentStore.Id);
if (subscription != null)
{
if (!subscription.Active)
{
_workflowMessageService.SendNewsLetterSubscriptionActivationMessage(subscription, _workContext.WorkingLanguage.Id);
}
result = _localizationService.GetResource("Newsletter.SubscribeEmailSent");
}
else
{
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");
}
success = true;
}
return Json(new
{
Success = success,
Result = result,
});
}
示例9: Can_save_and_load_nls
public void Can_save_and_load_nls()
{
var newGuid = Guid.NewGuid();
var now = new DateTime(2010, 01, 01);
var nls = new NewsLetterSubscription
{
Email = "[email protected]",
NewsLetterSubscriptionGuid = newGuid,
CreatedOnUtc = now,
Active = true
};
var fromDb = SaveAndLoadEntity(nls);
fromDb.ShouldNotBeNull();
fromDb.Email.ShouldEqual("[email protected]");
fromDb.NewsLetterSubscriptionGuid.ShouldEqual(newGuid);
fromDb.CreatedOnUtc.ShouldEqual(now);
fromDb.Active.ShouldBeTrue();
}
示例10: UpdateNewsLetterSubscription
/// <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
NewsLetterSubscription 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);
}
示例11: InsertNewsLetterSubscription
/// <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);
}
示例12: SendNewsLetterSubscriptionDeactivationMessage
/// <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);
//event notification
_eventPublisher.MessageTokensAdded(messageTemplate, orderTokens);
var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId);
var toEmail = subscription.Email;
var toName = "";
return SendNotification(messageTemplate, emailAccount,
languageId, orderTokens,
toEmail, toName);
}
示例13: VerifyUpdateEventIsFired
public void VerifyUpdateEventIsFired()
{
//Prepare the original result
var originalSubscription = new NewsLetterSubscription { Active = false, Email = "[email protected]" };
_newsLetterSubscriptionRepository.Stub(m => m.GetById(Arg<object>.Is.Anything)).Return(originalSubscription);
var service = new NewsLetterSubscriptionService(_dbContext, _newsLetterSubscriptionRepository,
_customerRepository, _eventPublisher, _customerService);
service.UpdateNewsLetterSubscription(new NewsLetterSubscription { Email = "[email protected]" });
_eventPublisher.AssertWasCalled(x => x.EntityUpdated(Arg<NewsLetterSubscription>.Is.Anything));
}
示例14: GenerateTokens
private IList<Token> GenerateTokens(NewsLetterSubscription subscription)
{
var tokens = new List<Token>();
_messageTokenProvider.AddStoreTokens(tokens);
_messageTokenProvider.AddNewsLetterSubscriptionTokens(tokens, subscription);
return tokens;
}
示例15: VerifyUpdateEventIsFired
public void VerifyUpdateEventIsFired()
{
var eventPublisher = MockRepository.GenerateStub<IEventPublisher>();
var repo = MockRepository.GenerateStub<IRepository<NewsLetterSubscription>>();
var context = MockRepository.GenerateStub<IDbContext>();
//Prepare the original result
var originalSubscription = new NewsLetterSubscription { Active = false, Email = "[email protected]" };
repo.Stub(m => m.GetById(Arg<object>.Is.Anything)).Return(originalSubscription);
var service = new NewsLetterSubscriptionService(context, repo, eventPublisher);
service.UpdateNewsLetterSubscription(new NewsLetterSubscription { Email = "[email protected]" });
eventPublisher.AssertWasCalled(x => x.EntityUpdated(Arg<NewsLetterSubscription>.Is.Anything));
}