/// <summary>
        /// Resolves the static text for a given static text type.
        /// </summary>
        /// <param name="staticTextType">Static text type for which to resolve the static text.</param>
        /// <param name="translationInfo">Translation informations used to translate the static text.</param>
        /// <returns>Static text for a given static text type.</returns>
        private IStaticText ResolveStaticText(StaticTextType staticTextType, ITranslationInfo translationInfo)
        {
            if (translationInfo == null)
            {
                throw new ArgumentNullException("translationInfo");
            }

            IStaticText staticText;

            if (_staticTextCache.ContainsKey(staticTextType))
            {
                staticText = _staticTextCache[staticTextType];
                staticText.Translate(translationInfo.CultureInfo);
                return(staticText);
            }

            staticText = _systemDataRepository.StaticTextGetByStaticTextType(staticTextType);
            foreach (var translation in staticText.Translations)
            {
                translation.Value = translation.Value.Replace("<html>", string.Empty).Replace("</html>", string.Empty);
            }
            staticText.Translate(translationInfo.CultureInfo);

            _staticTextCache.Add(staticTextType, staticText);
            return(staticText);
        }
示例#2
0
 public void TestThatStaticTextGetByStaticTextTypeReturnsStaticText()
 {
     foreach (var staticTextTypeToTest in Enum.GetValues(typeof(StaticTextType)).Cast <StaticTextType>())
     {
         var staticText = _systemDataRepository.StaticTextGetByStaticTextType(staticTextTypeToTest);
         Assert.That(staticText, Is.Not.Null);
     }
 }
示例#3
0
        /// <summary>
        /// Handles the communication so welcome letter will be dispatched to the household member.
        /// </summary>
        /// <param name="stakeholder">Stakeholder which data should be dispatched to.</param>
        /// <param name="householdMember">Household member which should receive the welcome letter.</param>
        /// <param name="translationInfo">Translation informations used to translate the data to dispatch.</param>
        protected override void HandleCommunication(IStakeholder stakeholder, IHouseholdMember householdMember, ITranslationInfo translationInfo)
        {
            var welcomeLetterStaticText = _systemDataRepository.StaticTextGetByStaticTextType(StaticTextType.WelcomeLetter);

            welcomeLetterStaticText.Translate(translationInfo.CultureInfo);

            _staticTextFieldMerge.AddMergeFields(householdMember, translationInfo);
            _staticTextFieldMerge.Merge(welcomeLetterStaticText, translationInfo);

            CommunicationRepository.SendMail(stakeholder.MailAddress, welcomeLetterStaticText.SubjectTranslation.Value, welcomeLetterStaticText.BodyTranslation.Value);
        }
        /// <summary>
        /// Functionality which handles a query for getting a specific static text.
        /// </summary>
        /// <param name="query">Query for getting the specific static text.</param>
        /// <returns>Static text.</returns>
        public virtual StaticTextView Query(TQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            var translationInfo = _systemDataRepository.Get <ITranslationInfo>(query.TranslationInfoIdentifier);
            var staticText      = _systemDataRepository.StaticTextGetByStaticTextType(StaticTextType);

            return(_foodWasteObjectMapper.Map <IStaticText, StaticTextView>(staticText, translationInfo.CultureInfo));
        }