예제 #1
0
        /// <summary>
        /// Creates a list of entities that includes each publishing status type 'count' times.
        /// For example if count is 2, the list will include 2 * 5 items (because we have 5 different publishing statuses).
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <typeparam name="TLanguageAvailability"></typeparam>
        /// <param name="count">Indicates how many of each publishing status type items the list will include.</param>
        /// <returns></returns>
        private static List <TEntity> CreateEntityList <TEntity, TRootEntity, TLanguageAvailability>(int count, IPublishingStatusCache publishingStatusCache) where TEntity :
        EntityIdentifierBase, IVersionedVolume <TRootEntity>, IPublishingStatus, IMultilanguagedEntity <TLanguageAvailability>, new()
            where TRootEntity : VersionedRoot <TEntity>
            where TLanguageAvailability : LanguageAvailability, new()
        {
            var list = new List <TEntity>();

            for (var i = 0; i < count; i++)
            {
                list.Add(CreateEntity <TEntity, TRootEntity, TLanguageAvailability>(publishingStatusCache.Get(PublishingStatus.Published)));
                list.Add(CreateEntity <TEntity, TRootEntity, TLanguageAvailability>(publishingStatusCache.Get(PublishingStatus.Draft)));
                list.Add(CreateEntity <TEntity, TRootEntity, TLanguageAvailability>(publishingStatusCache.Get(PublishingStatus.Modified)));
                list.Add(CreateEntity <TEntity, TRootEntity, TLanguageAvailability>(publishingStatusCache.Get(PublishingStatus.OldPublished)));
                list.Add(CreateEntity <TEntity, TRootEntity, TLanguageAvailability>(publishingStatusCache.Get(PublishingStatus.Deleted)));
            }

            return(list);
        }
예제 #2
0
        public ITranslationDefinitions <TIn, TOut> AddLanguageAvailability <TInLang, TOutLang>(Func <TIn, TInLang> fromProperty, Func <TOut, IMultilanguagedEntity <TOutLang> > languageAvailable) where TOutLang : class, ILanguageAvailability, new () where TInLang : class, ILanguagesAvailabilities
        {
            if (sourceInstance == null)
            {
                return(this);
            }
            EnsureCreateTargetInstance();
            var languagedTarget = languageAvailable(targetInstance);
            var inputProperty   = fromProperty(sourceInstance);

            if ((!clonedTargetApplied))
            {
                unitOfWork.LoadNavigationProperty(targetInstance, i => languageAvailable(i).LanguageAvailabilities);
            }

            inputProperty.LanguagesAvailabilities.ForEach(rLang =>
            {
                var availability = languagedTarget.LanguageAvailabilities.FirstOrDefault(i => i.LanguageId == rLang.LanguageId) ??
                                   languagedTarget.LanguageAvailabilities.AddAndReturn(new TOutLang()
                {
                    LanguageId = rLang.LanguageId
                });
                if (availability.StatusId == Guid.Empty)
                {
                    availability.StatusId = publishingStatusCache.Get(PublishingStatus.Draft);
                }
                if (availability.StatusId == publishingStatusCache.Get(PublishingStatus.Published))
                {
                    availability.StatusId = publishingStatusCache.Get(PublishingStatus.Modified);
                }
                availability.ModifiedBy = "forceUpdate";
            });

            return(this);
        }
예제 #3
0
 public PublishingStatusFilter(IPublishingStatusCache publishingStatusCache)
 {
     this.statusDeletedId = publishingStatusCache.Get(PublishingStatus.Deleted);
 }