/// <summary>
        /// Updates a message template
        /// </summary>
        /// <param name="messageTemplate">Message template</param>
        public virtual void UpdateMessageTemplate(MessageTemplate messageTemplate)
        {
            if (messageTemplate == null)
            {
                throw new ArgumentNullException("messageTemplate");
            }

            _messageTemplateRepository.Update(messageTemplate);

            _cacheManager.RemoveByPattern(MESSAGETEMPLATES_PATTERN_KEY);
        }
Beispiel #2
0
        public MessageTemplate Update(MessageTemplateDto messageTemplateDto)
        {
            Guard.IsNotNull(messageTemplateDto);

            if (_mtRepo.TryGetOne(messageTemplateDto, out var entity))
            {
                throw new EntityNotChangedException("Couldn't update the message template, because is hasn't changed");
            }

            var messageType = messageTemplateDto.Type;

            entity         = GetOne(messageType);
            entity.Subject = messageTemplateDto.Subject;
            entity.Body    = messageTemplateDto.Body;

            return(_cache.Update(messageType.ToString(), () => _mtRepo.Update(entity)));
        }