public virtual int SendVendorEmailValidationMessage(Customer customer, int languageId) { if (customer == null) throw new ArgumentNullException("customer"); var store = _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetActiveMessageTemplate("Vendor.EmailValidationMessage", store.Id); if (messageTemplate == null) return 0; //email account var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token>(); _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, customer); _messageTokenProvider.AddVendorTokens(tokens, customer); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = customer.Email; var toName = customer.GetFullName(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
public virtual void AddCustomerTokens(IList<Token> tokens, Customer customer) { tokens.Add(new Token("Customer.Email", customer.Email)); tokens.Add(new Token("Customer.Username", customer.Username)); tokens.Add(new Token("Customer.FullName", customer.GetFullName())); tokens.Add(new Token("Customer.FirstName", customer.GetAttribute<string>(SystemCustomerAttributeNames.FirstName))); tokens.Add(new Token("Customer.LastName", customer.GetAttribute<string>(SystemCustomerAttributeNames.LastName))); tokens.Add(new Token("Customer.VatNumber", customer.GetAttribute<string>(SystemCustomerAttributeNames.VatNumber))); tokens.Add(new Token("Customer.VatNumberStatus", ((VatNumberStatus)customer.GetAttribute<int>(SystemCustomerAttributeNames.VatNumberStatusId)).ToString())); //note: we do not use SEO friendly URLS because we can get errors caused by having .(dot) in the URL (from the email address) //TODO add a method for getting URL (use routing because it handles all SEO friendly URLs) string passwordRecoveryUrl = string.Format("{0}passwordrecovery/confirm?token={1}&email={2}", GetStoreUrl(), customer.GetAttribute<string>(SystemCustomerAttributeNames.PasswordRecoveryToken), HttpUtility.UrlEncode(customer.Email)); string accountActivationUrl = string.Format("{0}customer/activation?token={1}&email={2}", GetStoreUrl(), customer.GetAttribute<string>(SystemCustomerAttributeNames.AccountActivationToken), HttpUtility.UrlEncode(customer.Email)); var wishlistUrl = string.Format("{0}wishlist/{1}", GetStoreUrl(), customer.CustomerGuid); tokens.Add(new Token("Customer.PasswordRecoveryURL", passwordRecoveryUrl, true)); tokens.Add(new Token("Customer.AccountActivationURL", accountActivationUrl, true)); tokens.Add(new Token("Wishlist.URLForCustomer", wishlistUrl, true)); //event notification _eventPublisher.EntityTokensAdded(customer, tokens); }
public virtual void AddCustomerTokens(IList<Token> tokens, Customer customer) { tokens.Add(new Token("Customer.Email", customer.Email)); tokens.Add(new Token("Customer.Username", customer.Username)); tokens.Add(new Token("Customer.FullName", customer.GetFullName())); tokens.Add(new Token("Customer.VatNumber", customer.VatNumber)); tokens.Add(new Token("Customer.VatNumberStatus", customer.VatNumberStatus.ToString())); //TODO add a method for getting URL (use routing because it handles all SEO friendly URLs) string passwordRecoveryUrl = string.Format("{0}passwordrecovery/confirm?token={1}&email={2}", _webHelper.GetStoreLocation(false), customer.GetAttribute<string>(SystemCustomerAttributeNames.PasswordRecoveryToken), customer.Email); string accountActivationUrl = string.Format("{0}customer/activation?token={1}&email={2}", _webHelper.GetStoreLocation(false), customer.GetAttribute<string>(SystemCustomerAttributeNames.AccountActivationToken), customer.Email); var wishlistUrl = string.Format("{0}wishlist/{1}", _webHelper.GetStoreLocation(false), customer.CustomerGuid); tokens.Add(new Token("Customer.PasswordRecoveryURL", passwordRecoveryUrl, true)); tokens.Add(new Token("Customer.AccountActivationURL", accountActivationUrl, true)); tokens.Add(new Token("Wishlist.URLForCustomer", wishlistUrl, true)); }
/// <summary> /// Sends a forum subscription message to a customer /// </summary> /// <param name="customer">Customer instance</param> /// <param name="forumPost">Forum post</param> /// <param name="forumTopic">Forum Topic</param> /// <param name="forum">Forum</param> /// <param name="friendlyForumTopicPageIndex">Friendly (starts with 1) forum topic page to use for URL generation</param> /// <param name="languageId">Message language identifier</param> /// <returns>Queued email identifier</returns> public int SendNewForumPostMessage(Customer customer, ForumPost forumPost, ForumTopic forumTopic, Forum forum, int friendlyForumTopicPageIndex, int languageId) { if (customer == null) { throw new ArgumentNullException("customer"); } var messageTemplate = GetLocalizedActiveMessageTemplate("Forums.NewForumPost", languageId); if (messageTemplate == null || !messageTemplate.IsActive) { return 0; } var tokens = GenerateTokens(forumPost, friendlyForumTopicPageIndex, forumPost.Id); var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); var toEmail = customer.Email; var toName = customer.GetFullName(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
protected virtual void PrepareMyBidsModel(AUMyBidsModel model, List<int> bidProducts, Customer customer, bool isEditable = true) { if (bidProducts == null) throw new ArgumentNullException("bidProducts"); if (model == null) throw new ArgumentNullException("model"); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var AUConsignorSettings = _settings.LoadSetting<Nop.Plugin.Misc.AUConsignor.Domain.AUConsignorSettings>(storeScope); AUStoreTypeEnum storeType = (AUStoreTypeEnum)AUConsignorSettings.StoreTypeId; model.StoreType = storeType; //needed this beyond IsEditable because if don't come in with customer guid from share wishlist email you //still don;t want them to enter bids if they're a guest if (_workContext.CurrentCustomer.IsGuest()) { model.IsGuest = true; } else { model.IsGuest = false; } model.EmailWishlistEnabled = _shoppingCartSettings.EmailWishlistEnabled; model.IsEditable = isEditable; model.DisplayAddToCart = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart); model.DisplayTaxShippingInfo = _catalogSettings.DisplayTaxShippingInfoWishlist; if (bidProducts.Count == 0) return; #region Simple properties //var customer = cart.GetCustomer(); //NJM: changed to pass in parameter model.CustomerGuid = customer.CustomerGuid; model.CustomerFullname = customer.GetFullName(); model.ShowProductImages = _shoppingCartSettings.ShowProductImagesOnShoppingCart; model.ShowSku = _catalogSettings.ShowProductSku; //cart warnings //var cartWarnings = _shoppingCartService.GetShoppingCartWarnings(cart, "", false); //foreach (var warning in cartWarnings) // model.Warnings.Add(warning); #endregion #region MyBids items foreach (int p in bidProducts) { var product = _productService.GetProductById(p); var bidItemModel = new AUMyBidsModel.MyBidItemItemModel { Id = product.Id, //Sku = sci.Product.FormatSku(sci.AttributesXml, _productAttributeParser), Sku = product.Sku, ProductId = product.Id, ProductName = product.GetLocalized(x => x.Name), ProductSeName = product.GetSeName(), //Quantity = sci.Quantity, StockQuantity = product.StockQuantity, //TODO: where does AttributeInfo come from and how is it used //AttributeInfo = _productAttributeFormatter.FormatAttributes(sci.Product, sci.AttributesXml), LotBidEntry = _lotService.GetLotBidEntryModel(product.Id) }; //NJM: count lots as separate from products so can determine if need to show product wishlist and lot wishlist in view if (bidItemModel.LotBidEntry.ProductIsLot) { model.TotalLots += 1; } //TODO: fill in the lot bid entry model in the shopping cart only if auction site //allowed quantities //NJM: do not use allowed quantities for biddable lots. StockQuantity will be used for "dup lots" //(not grouped products which is used for variants) //var allowedQuantities = sci.Product.ParseAllowedQuantities(); //foreach (var qty in allowedQuantities) //{ // cartItemModel.AllowedQuantities.Add(new SelectListItem // { // Text = qty.ToString(), // Value = qty.ToString(), // Selected = sci.Quantity == qty // }); //} //recurring info //NJM: do not use recurring info for biddable lots. //if (sci.Product.IsRecurring) // cartItemModel.RecurringInfo = string.Format(_localizationService.GetResource("ShoppingCart.RecurringPeriod"), sci.Product.RecurringCycleLength, sci.Product.RecurringCyclePeriod.GetLocalizedEnum(_localizationService, _workContext)); //rental info //NJM: do not use rental info for biddable lots. //if (sci.Product.IsRental) //{ // var rentalStartDate = sci.RentalStartDateUtc.HasValue ? sci.Product.FormatRentalDate(sci.RentalStartDateUtc.Value) : ""; // var rentalEndDate = sci.RentalEndDateUtc.HasValue ? sci.Product.FormatRentalDate(sci.RentalEndDateUtc.Value) : ""; // cartItemModel.RentalInfo = string.Format(_localizationService.GetResource("ShoppingCart.Rental.FormattedDate"), // rentalStartDate, rentalEndDate); //} //unit prices //TODO: check use of callforprice for unsolds //if (product.CallForPrice) //{ // cartItemModel.UnitPrice = _localizationService.GetResource("Products.CallForPrice"); //} //else //{ // decimal taxRate; // decimal shoppingCartUnitPriceWithDiscountBase = _taxService.GetProductPrice(sci.Product, _priceCalculationService.GetUnitPrice(sci), out taxRate); // decimal shoppingCartUnitPriceWithDiscount = _currencyService.ConvertFromPrimaryStoreCurrency(shoppingCartUnitPriceWithDiscountBase, _workContext.WorkingCurrency); // cartItemModel.UnitPrice = _priceFormatter.FormatPrice(shoppingCartUnitPriceWithDiscount); //} //subtotal, discount //NJM: subtotal, discount not currently used for lots //TODO: check use of subtotal, discount for lots //if (sci.Product.CallForPrice) //{ // cartItemModel.SubTotal = _localizationService.GetResource("Products.CallForPrice"); //} //else //{ // //sub total // Discount scDiscount; // decimal shoppingCartItemDiscountBase; // decimal taxRate; // decimal shoppingCartItemSubTotalWithDiscountBase = _taxService.GetProductPrice(sci.Product, _priceCalculationService.GetSubTotal(sci, true, out shoppingCartItemDiscountBase, out scDiscount), out taxRate); // decimal shoppingCartItemSubTotalWithDiscount = _currencyService.ConvertFromPrimaryStoreCurrency(shoppingCartItemSubTotalWithDiscountBase, _workContext.WorkingCurrency); // cartItemModel.SubTotal = _priceFormatter.FormatPrice(shoppingCartItemSubTotalWithDiscount); // //display an applied discount amount // if (scDiscount != null) // { // shoppingCartItemDiscountBase = _taxService.GetProductPrice(sci.Product, shoppingCartItemDiscountBase, out taxRate); // if (shoppingCartItemDiscountBase > decimal.Zero) // { // decimal shoppingCartItemDiscount = _currencyService.ConvertFromPrimaryStoreCurrency(shoppingCartItemDiscountBase, _workContext.WorkingCurrency); // cartItemModel.Discount = _priceFormatter.FormatPrice(shoppingCartItemDiscount); // } // } //} //picture if (_shoppingCartSettings.ShowProductImagesOnShoppingCart) { bidItemModel.Picture = PrepareMyBidPictureModel(bidItemModel, _mediaSettings.CartThumbPictureSize, true, bidItemModel.ProductName); //TODO: clean up this signature } //item warnings //var itemWarnings = _shoppingCartService.GetShoppingCartItemWarnings( // _workContext.CurrentCustomer, // sci.ShoppingCartType, // sci.Product, // sci.StoreId, // sci.AttributesXml, // sci.CustomerEnteredPrice, // sci.RentalStartDateUtc, // sci.RentalEndDateUtc, // sci.Quantity, // false); var itemWarnings = new List<string>(); foreach (var warning in itemWarnings) bidItemModel.Warnings.Add(warning); model.Lots.Add(bidItemModel); } }
protected CustomerModel PrepareCustomerModelForList(Customer customer) { return new CustomerModel() { Id = customer.Id, Email = !String.IsNullOrEmpty(customer.Email) ? customer.Email : (customer.IsGuest() ? _localizationService.GetResource("Admin.Customers.Guest") : "Unknown"), Username = customer.Username, FullName = customer.GetFullName(), //CustomerRoleNames = GetCustomerRolesNames(customer.CustomerRoles.ToList()), Active = customer.Active, //CreatedOn = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc), //LastActivityDate = _dateTimeHelper.ConvertToUserTime(customer.LastActivityDateUtc, DateTimeKind.Utc), }; }
public int SendProductReviewNotification(Customer customer, List<Product> unreviewedProducts, int languageId, int storeId) { var store = _storeService.GetStoreById(storeId) ?? _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("MobSocial.ProductReviewNotification", store.Id); if (messageTemplate == null) return 0; var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token>(); _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, customer); var productUrls = ProductListToHtmlTable(unreviewedProducts, languageId, storeId); tokens.Add(new Token("ProductUrls", productUrls)); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = customer.Email; var toName = customer.GetFullName().ToTitleCase(); var emailId = SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); return emailId; }
/// <summary> /// Sends a welcome message to a customer /// </summary> /// <param name="customer">Customer instance</param> /// <param name="languageId">Message language identifier</param> /// <returns>Queued email identifier</returns> public virtual int SendCustomerWelcomeMessage(Customer customer, int languageId) { if (customer == null) throw new ArgumentNullException("customer"); languageId = EnsureLanguageIsActive(languageId); var messageTemplate = GetLocalizedActiveMessageTemplate("Customer.WelcomeMessage", languageId); if (messageTemplate == null) return 0; var customerTokens = GenerateTokens(customer); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, customerTokens); var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); var toEmail = customer.Email; var toName = customer.GetFullName(); return SendNotification(messageTemplate, emailAccount, languageId, customerTokens, toEmail, toName); }
public int SendEventInvitationNotification(Customer customer, int languageId, int storeId) { var store = _storeService.GetStoreById(storeId) ?? _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("MobSocial.EventInvitationNotification", store.Id); if (messageTemplate == null) return 0; var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token>(); _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, customer); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = customer.Email; var toName = customer.GetFullName().ToTitleCase(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
public int SendXDaysToBattleStartNotificationToParticipant(Customer receiver, VideoBattle videoBattle, int languageId, int storeId) { var store = _storeService.GetStoreById(storeId) ?? _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("MobSocial.xDaysToBattleStartNotification", store.Id); if (messageTemplate == null) return 0; var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //find the remaining days to start of battle var timeSpan = (int)Math.Ceiling(videoBattle.VotingStartDate.Subtract(DateTime.UtcNow).TotalDays); var formattedString = timeSpan > 1 ? string.Format("in {0} days", timeSpan) : "tomorrow"; //tokens var tokens = new List<Token> { new Token("Battle.Title", videoBattle.Name, true), new Token("Battle.Url", string.Format("{0}/VideoBattle/{1}", store.Url, videoBattle.GetSeName(_workContext.WorkingLanguage.Id, true, false)), true), new Token("Battle.StartDaysString", formattedString , true) }; _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, receiver); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = receiver.Email; var toName = receiver.GetFullName().ToTitleCase(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
public int SendVotingReminderNotification(Customer sender, string receiverEmail, string receiverName, VideoBattle videoBattle, int languageId, int storeId) { var store = _storeService.GetStoreById(storeId) ?? _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("MobSocial.SomeoneInvitedYouToVoteNotification", store.Id); if (messageTemplate == null) return 0; var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token> { new Token("VideoBattle.Title", videoBattle.Name, true), new Token("VideoBattle.Url", string.Format("{0}/VideoBattles/VideoBattle/{1}", store.Url, videoBattle.Id) , true), new Token("Inviter.Name", sender.GetFullName() , true) }; _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, sender); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = receiverEmail; var toName = receiverName; return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
public int SendVotingReminderNotification(Customer sender, Customer receiver, VideoBattle videoBattle, int languageId, int storeId) { return SendVotingReminderNotification(sender, receiver.Email, receiver.GetFullName().ToTitleCase(), videoBattle, languageId, storeId); }
public int SendVideoBattleSignupNotification(Customer challenger, Customer challengee, VideoBattle videoBattle, int languageId, int storeId) { var store = _storeService.GetStoreById(storeId) ?? _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("MobSocial.VideoBattleSignupNotification", store.Id); if (messageTemplate == null) return 0; var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token> { new Token("VideoBattle.Title", videoBattle.Name, true), new Token("VideoBattle.Url", string.Format("{0}/VideoBattles/VideoBattle/{1}", store.Url, videoBattle.Id) , true), new Token("Challenger.Name", challengee.GetFullName() , true) }; _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, challengee); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = challenger.Email; var toName = challenger.GetFullName().ToTitleCase(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
public int SendSponsorshipStatusChangeNotification(Customer receiver, SponsorshipStatus sponsorshipStatus, VideoBattle videoBattle, int languageId, int storeId) { var store = _storeService.GetStoreById(storeId) ?? _storeContext.CurrentStore; languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("MobSocial.SponsorshipStatusChangeNotification", store.Id); if (messageTemplate == null) return 0; var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token> { new Token("Battle.Title", videoBattle.Name, true), new Token("Battle.Url", string.Format("{0}/VideoBattle/{1}", store.Url, videoBattle.GetSeName(_workContext.WorkingLanguage.Id, true, false)), true), new Token("Sponsorship.Status", sponsorshipStatus.ToString() , true) }; _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, receiver); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = receiver.Email; var toName = receiver.GetFullName().ToTitleCase(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
public int SendSomeoneChallengedYouForABattleNotification(Customer challenger, Customer challengee, VideoBattle videoBattle, int languageId, int storeId) { return SendSomeoneChallengedYouForABattleNotification(challenger, challenger.Email, challenger.GetFullName().ToTitleCase(), videoBattle, languageId, storeId); }
/// <summary> /// Sends a forum subscription message to a customer /// </summary> /// <param name="customer">Customer instance</param> /// <param name="forumPost">Forum post</param> /// <param name="forumTopic">Forum Topic</param> /// <param name="forum">Forum</param> /// <param name="friendlyForumTopicPageIndex">Friendly (starts with 1) forum topic page to use for URL generation</param> /// <param name="languageId">Message language identifier</param> /// <returns>Queued email identifier</returns> public int SendNewForumPostMessage(Customer customer, ForumPost forumPost, ForumTopic forumTopic, Forum forum, int friendlyForumTopicPageIndex, int languageId) { if (customer == null) { throw new ArgumentNullException("customer"); } var store = _storeContext.CurrentStore; var messageTemplate = GetActiveMessageTemplate("Forums.NewForumPost", store.Id); if (messageTemplate == null ) { return 0; } //email account var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token>(); _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddForumPostTokens(tokens, forumPost); _messageTokenProvider.AddForumTopicTokens(tokens, forumPost.ForumTopic, friendlyForumTopicPageIndex, forumPost.Id); _messageTokenProvider.AddForumTokens(tokens, forumPost.ForumTopic.Forum); _messageTokenProvider.AddCustomerTokens(tokens, customer); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = customer.Email; var toName = customer.GetFullName(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
protected virtual CustomerModel PrepareCustomerModelForList(Customer customer) { return new CustomerModel { Id = customer.Id, Email = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest"), Username = customer.Username, FullName = customer.GetFullName(), Company = customer.GetAttribute<string>(SystemCustomerAttributeNames.Company), Phone = customer.GetAttribute<string>(SystemCustomerAttributeNames.Phone), ZipPostalCode = customer.GetAttribute<string>(SystemCustomerAttributeNames.ZipPostalCode), CustomerRoleNames = GetCustomerRolesNames(customer.CustomerRoles.ToList()), Active = customer.Active, CreatedOn = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc), LastActivityDate = _dateTimeHelper.ConvertToUserTime(customer.LastActivityDateUtc, DateTimeKind.Utc), }; }
private CustomerModel PrepareCustomerModelForList(Customer customer) { return new CustomerModel() { Id = customer.Id, Email = !String.IsNullOrEmpty(customer.Email) ? customer.Email : (customer.IsGuest() ? "Guest" : "Unknown"), Username = customer.Username, FullName = customer.GetFullName(), CustomerRoleNames = GetCustomerRolesNames(customer.CustomerRoles.ToList()), Active = customer.Active, CreatedOn = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc), LastActivityDate = _dateTimeHelper.ConvertToUserTime(customer.LastActivityDateUtc, DateTimeKind.Utc), }; }
/// <summary> /// Sends a forum subscription message to a customer /// </summary> /// <param name="customer">Customer instance</param> /// <param name="forumTopic">Forum Topic</param> /// <param name="forum">Forum</param> /// <param name="languageId">Message language identifier</param> /// <returns>Queued email identifier</returns> public int SendNewForumTopicMessage(Customer customer, ForumTopic forumTopic, Forum forum, int languageId) { if (customer == null) { throw new ArgumentNullException("customer"); } var messageTemplate = GetLocalizedActiveMessageTemplate("Forums.NewForumTopic", languageId); if (messageTemplate == null || !messageTemplate.IsActive) { return 0; } var tokens = GenerateTokens(forumTopic); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); var toEmail = customer.Email; var toName = customer.GetFullName(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }
public int SendPendingFriendRequestNotification(Customer customer, int friendRequestCount, int languageId, int storeId) { var store = _storeService.GetStoreById(storeId); languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplate = GetLocalizedActiveMessageTemplate("MobSocial.PendingFriendRequestNotification", store.Id); if (messageTemplate == null) return 0; var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); //tokens var tokens = new List<Token>(); _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); _messageTokenProvider.AddCustomerTokens(tokens, customer); tokens.Add(new Token("FriendRequestCount", friendRequestCount.ToString())); //event notification _eventPublisher.MessageTokensAdded(messageTemplate, tokens); var toEmail = customer.Email; var toName = customer.GetFullName().ToTitleCase(); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }