コード例 #1
0
        private ContentHistoryItem Convert(IHistorical content)
        {
            var canRestore = content.Status == ContentStatus.Archived;

            var contentType = content.GetType();

            if (contentType == typeof(HtmlContentWidget) || contentType == typeof(ServerControlWidget))
            {
                canRestore = canRestore && userHasAdministrationRole;
            }
            else
            {
                canRestore = canRestore && userHasPublishRole;
            }

            return(new ContentHistoryItem
            {
                Id = content.Id,
                Version = content.Version,
                StatusName = historyService.GetStatusName(content.Status),
                Status = content.Status,
                ArchivedByUser = content.Status == ContentStatus.Archived ? content.CreatedByUser : null,
                ArchivedOn = content.Status == ContentStatus.Archived ? content.CreatedOn : (DateTime?)null,
                DisplayedFor = content.Status == ContentStatus.Archived && content.PublishedOn != null
                                   ? content.CreatedOn - content.PublishedOn.Value
                                   : (TimeSpan?)null,
                PublishedByUser = content.Status == ContentStatus.Published || content.Status == ContentStatus.Archived ? content.PublishedByUser : null,
                PublishedOn = content.Status == ContentStatus.Published || content.Status == ContentStatus.Archived ? content.PublishedOn : null,
                CreatedOn = content.CreatedOn,
                CanCurrentUserRestoreIt = canRestore
            });
        }
コード例 #2
0
 /// <summary>
 /// Sets the history on a data model with this audit's information.
 /// </summary>
 /// <param name="historicalEntity">The historical entity.</param>
 public override void SetHistory(IHistorical historicalEntity)
 {
     if (historicalEntity.History == null)
     {
         historicalEntity.History = new History();
     }
     historicalEntity.History.RevisedBy = this.User.Id;
     historicalEntity.History.RevisedOn = this.Date;
 }
コード例 #3
0
        /// <summary>
        /// Determines whether content contains search query.
        /// </summary>
        /// <param name="f">The f.</param>
        /// <param name="searchQuery">The search query.</param>
        /// <returns>
        ///   <c>true</c> if [contains search query] [the specified f]; otherwise, <c>false</c>.
        /// </returns>
        private bool ContainsSearchQuery(IHistorical f, string searchQuery)
        {
            if (!string.IsNullOrWhiteSpace(searchQuery))
            {
                var statusName = GetStatusName(f.Status).ToLower();

                return((f.Status == ContentStatus.Published && !string.IsNullOrEmpty(f.PublishedByUser) && f.PublishedByUser.ToLower().Contains(searchQuery)) ||
                       f.CreatedByUser.ToLower().Contains(searchQuery) ||
                       (!string.IsNullOrEmpty(statusName) && statusName.Contains(searchQuery)));
            }
            return(true);
        }
コード例 #4
0
 /// <summary>
 /// Sets the history on a data model with this audit's information.
 /// </summary>
 /// <param name="historicalEntity">The historical entity.</param>
 public override void SetHistory(IHistorical historicalEntity)
 {
     historicalEntity.History.RevisedBy = this.User.Id;
     historicalEntity.History.RevisedOn = this.Date;
 }
コード例 #5
0
 /// <summary>
 /// Determines whether content is valid historical content.
 /// </summary>
 /// <param name="f">The f.</param>
 /// <returns>
 ///   <c>true</c> if content is valid historical content; otherwise, <c>false</c>.
 /// </returns>
 private bool IsValidHistoricalContent(IHistorical f)
 {
     return(!f.IsDeleted && (f.Status == ContentStatus.Published || f.Status == ContentStatus.Draft || f.Status == ContentStatus.Archived));
 }
コード例 #6
0
ファイル: Audit.cs プロジェクト: thomaspmorgan/eca-kmt2
 /// <summary>
 ///
 /// </summary>
 /// <param name="historicalEntity"></param>
 public override void SetHistory(IHistorical historicalEntity)
 {
     Contract.Requires(historicalEntity != null, "The historical entity must not be null.");
 }
コード例 #7
0
ファイル: Audit.cs プロジェクト: thomaspmorgan/eca-kmt2
 /// <summary>
 /// Updates the history information on the given entity with this history.
 /// </summary>
 /// <param name="historicalEntity">The historical entity.</param>
 public abstract void SetHistory(IHistorical historicalEntity);
コード例 #8
0
 /// <summary>
 /// Determines whether content is valid historical content.
 /// </summary>
 /// <param name="f">The f.</param>
 /// <returns>
 ///   <c>true</c> if content is valid historical content; otherwise, <c>false</c>.
 /// </returns>
 private bool IsValidHistoricalContent(IHistorical f)
 {
     return !f.IsDeleted && (f.Status == ContentStatus.Published || f.Status == ContentStatus.Draft || f.Status == ContentStatus.Archived);
 }
コード例 #9
0
        /// <summary>
        /// Determines whether content contains search query.
        /// </summary>
        /// <param name="f">The f.</param>
        /// <param name="searchQuery">The search query.</param>
        /// <returns>
        ///   <c>true</c> if [contains search query] [the specified f]; otherwise, <c>false</c>.
        /// </returns>
        private bool ContainsSearchQuery(IHistorical f, string searchQuery)
        {
            if (!string.IsNullOrWhiteSpace(searchQuery))
            {
                var statusName = GetStatusName(f.Status).ToLower();

                return (f.Status == ContentStatus.Published && !string.IsNullOrEmpty(f.PublishedByUser) && f.PublishedByUser.ToLower().Contains(searchQuery))
                    || f.CreatedByUser.ToLower().Contains(searchQuery)
                    || (!string.IsNullOrEmpty(statusName) && statusName.Contains(searchQuery));
            }
            return true;
        }
コード例 #10
0
 public DemandsController(IHistorical demandsHandlerInjection)
 {
     demandsHandler = demandsHandlerInjection; //Injection of dependency
 }