示例#1
0
        public string GetContent(Guid moduleId, Guid languageId = new Guid())
        {
            return(_cacheManager.Get(string.Format(CacheKeys.TextModuleCacheKey, moduleId, languageId), () =>
            {
                var textModule = _textRepository.GetByModuleId(moduleId);

                if (textModule == null)
                {
                    return null;
                }

                var publishedVersion = textModule.TextVersions.FirstOrDefault(x => x.Status == TextVersionStatus.Published);

                var content = publishedVersion != null ? publishedVersion.Content : string.Empty;

                if (languageId != Guid.Empty)
                {
                    var localisedVersion =
                        publishedVersion.TextLocalisations.FirstOrDefault(x => x.LanguageId == languageId);

                    if (localisedVersion != null && !string.IsNullOrEmpty(localisedVersion.Content))
                    {
                        content = localisedVersion.Content;
                    }
                }

                return content;
            }));
        }
示例#2
0
        public string GetContent(Guid moduleId)
        {
            return(_cacheManager.Get(string.Format(CacheKeys.TextModuleCacheKey, moduleId), () =>
            {
                var textModule = _textRepository.GetByModuleId(moduleId);

                if (textModule == null)
                {
                    return null;
                }

                var publishedVersion = textModule.TextVersions.FirstOrDefault(x => x.Status == TextVersionStatus.Published);

                return publishedVersion != null ? publishedVersion.Content : string.Empty;
            }));
        }
示例#3
0
        public IAggregateRoot Handle(AddVersion command)
        {
            var textModule = _textModuleRepository.GetByModuleId(command.ModuleId);

            if (textModule == null)
            {
                throw new Exception("Text module not found.");
            }

            textModule.AddVersion(command, _validator);

            _textModuleRepository.Update(textModule);

            return(textModule);
        }