コード例 #1
0
        public int SendSponsorshipStatusChangeNotification(User 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.AddUserTokens(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));
        }
コード例 #2
0
 public void SendSponsorshipStatusChangeNotification(User receiver, SponsorshipStatus sponsorshipStatus,
                                                     VideoBattle videoBattleUser)
 {
     throw new System.NotImplementedException();
 }
コード例 #3
0
        public int SendSponsorshipStatusChangeNotification(User 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.AddUserTokens(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);
        }
コード例 #4
0
        public void UpdateSponsorStatus(int sponsorUserId, int battleId, BattleType battleType, SponsorshipStatus sponsorshipStatus)
        {
            var sponsors = GetSponsors(sponsorUserId, battleId, battleType, null);

            foreach (var sponsor in sponsors)
            {
                sponsor.SponsorshipStatus = sponsorshipStatus;
                //update
                Update(sponsor);
                //TODO: Update all in one go to improve performance
            }

            //if it's an approval, lets save sponsor data which will contain details about the sponsorship display part
            if (sponsorshipStatus != SponsorshipStatus.Accepted)
            {
                return;
            }

            var sponsorData = GetSponsorData(battleId, battleType, sponsorUserId) ?? new SponsorData()
            {
                BattleType        = battleType,
                BattleId          = battleId,
                SponsorCustomerId = sponsorUserId,
                PictureId         = 0,
                DateCreated       = DateTime.UtcNow,
                DateUpdated       = DateTime.UtcNow,
                DisplayName       = "",
                DisplayOrder      = 0,
                TargetUrl         = ""
            };

            SaveSponsorData(sponsorData);
        }