Example #1
0
        /// <summary>
        /// Publishes the content in master state. Content becomes live after the publish.
        /// </summary>
        /// <param name="item">Content in master state that is to be published.</param>
        public Telerik.Sitefinity.GenericContent.Model.Content Publish(Telerik.Sitefinity.GenericContent.Model.Content item)
        {
            var product = item as ProductItem;

            if (product != null)
            {
                return(this.Publish(product));
            }
            throw new NotSupportedException();
        }
Example #2
0
        /// <summary>
        /// Schedule a content item - to be published from one date to another
        /// </summary>
        /// <param name="item">Content item in master state</param>
        /// <param name="publicationDate">Point in time at which the item will be visible on the public side</param>
        /// <param name="expirationDate">Point in time at which the item will no longer be visible on the public side or null if the item should never expire</param>
        public Telerik.Sitefinity.GenericContent.Model.Content Schedule(Telerik.Sitefinity.GenericContent.Model.Content item, DateTime publicationDate, DateTime?expirationDate)
        {
            var product = item as ProductItem;

            if (product != null)
            {
                return(this.Schedule(product, publicationDate, expirationDate));
            }
            throw new NotSupportedException();
        }
Example #3
0
        /// <summary>
        /// Checks if <paramref name="item"/> is checked out by user with a specified id
        /// </summary>
        /// <param name="item">Item to test</param>
        /// <param name="userId">Id of the user to check if he/she checked out <paramref name="item"/></param>
        /// <returns>True if it was checked out by a user with the specified id, false otherwize</returns>
        public bool IsCheckedOutBy(Telerik.Sitefinity.GenericContent.Model.Content item, Guid userId)
        {
            var product = item as ProductItem;

            if (product != null)
            {
                return(this.IsCheckedOutBy(product, userId));
            }
            throw new NotSupportedException();
        }
Example #4
0
        /// <summary>
        /// Get a temp for <paramref name="cnt"/>, if it exists.
        /// </summary>
        /// <param name="cnt">Content item to get a temp for</param>
        /// <returns>Temp version of <paramref name="cnt"/>, if it exists.</returns>
        /// <exception cref="ArgumentNullException">When <paramref name="cnt"/> is <c>null</c>.</exception>
        public Telerik.Sitefinity.GenericContent.Model.Content GetTemp(Telerik.Sitefinity.GenericContent.Model.Content cnt)
        {
            var product = cnt as ProductItem;

            if (product != null)
            {
                return(this.GetTemp(product));
            }
            throw new NotSupportedException();
        }
Example #5
0
        /// <summary>
        /// Returns ID of the user that checked out the item, or Guid.Empty if it is not checked out
        /// </summary>
        /// <param name="item">Item to get the user ID it is locked by</param>
        /// <returns>ID of the user that ckecked out the item or Guid.Empty if the item is not checked out.</returns>
        public Guid GetCheckedOutBy(Telerik.Sitefinity.GenericContent.Model.Content item)
        {
            var product = item as ProductItem;

            if (product != null)
            {
                return(this.GetCheckedOutBy(product));
            }
            throw new NotSupportedException();
        }
        /// <summary>
        /// Get a video from the given item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <returns>
        /// The video.
        /// </returns>
        public static VideoModel GetVideo(this ContentModel item, string fieldName)
        {
            if (item == null || !item.DoesFieldExist(fieldName))
            {
                return(null);
            }

            Video sfContent = item.GetOriginal().GetRelatedItems <Video>(fieldName).FirstOrDefault();

            return(sfContent != null ? new VideoModel(sfContent) : null);
        }
        /// <summary>
        /// Get a single image from a content.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <returns>
        /// Telerik.Sitefinity.Libraries.Model.Image object.
        /// </returns>
        public static DocumentModel GetDocument(this ContentModel item, string fieldName)
        {
            if (!item.DoesFieldExist(fieldName))
            {
                return(null);
            }

            var sfContent = item.GetOriginal().GetRelatedItems <Document>(fieldName).FirstOrDefault();

            return(sfContent != null ? new DocumentModel(sfContent) : null);
        }
        /// <summary>
        /// Get a single image from a content.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <returns>
        /// The image.
        /// </returns>
        public static ImageModel GetImage(this ContentModel item, string fieldName)
        {
            //VALIDATE INPUT
            if (!item.DoesFieldExist(fieldName))
            {
                return(null);
            }

            var sfContent = item.GetOriginal().GetRelatedItems <Image>(fieldName).FirstOrDefault();

            return(sfContent != null ? new ImageModel(sfContent) : null);
        }
Example #9
0
        /// <summary>
        /// Copy one item to another for the uses of content lifecycle management
        /// </summary>
        /// <param name="source">Item to copy from</param>
        /// <param name="destination">Item to copy to</param>
        public void Copy(Telerik.Sitefinity.GenericContent.Model.Content source, Telerik.Sitefinity.GenericContent.Model.Content destination)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }
            var productSource      = source as ProductItem;
            var productDestination = destination as ProductItem;

            if (productSource == null || productDestination == null)
            {
                throw new ArgumentException("Source and destination must be of the same type");
            }
            this.Copy(productSource, productDestination);
        }
        /// <summary>
        /// Copy one item to another for the uses of content lifecycle management
        /// </summary>
        /// <param name="source">Item to copy from</param>
        /// <param name="destination">Item to copy to</param>
        public void Copy(Telerik.Sitefinity.GenericContent.Model.Content source, Telerik.Sitefinity.GenericContent.Model.Content destination)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }
            var itemSource      = source as RealEstateItem;
            var itemDestination = destination as RealEstateItem;

            if (itemSource == null || itemDestination == null)
            {
                throw new ArgumentException("Source and destination must be of the same type");
            }
            this.Copy(itemSource, itemDestination);
        }
        private IQueryable <Comment> GetCommentsQuery(Telerik.Sitefinity.GenericContent.Model.Content dataItem)
        {
            var id = dataItem.Id;
            IQueryable <Comment> query = null;
            var commentsSettings       = new CommentsSettingsWrapper(dataItem, this.MasterViewDefinition.CommentsSettingsDefinition);

            if ((bool)commentsSettings.HideCommentsAfterNumberOfDays)
            {
                var numberOfDaysToHideComments = (int)commentsSettings.NumberOfDaysToHideComments;
                var duration = new TimeSpan(numberOfDaysToHideComments, 0, 0, 0);
                query = this.Manager.GetComments().Where <Comment>(c => c.CommentedItemID == id &&
                                                                   c.CommentStatus == CommentStatus.Published &&
                                                                   c.DateCreated > DateTime.UtcNow.Subtract(duration));
            }
            else
            {
                query = this.Manager.GetComments().Where <Comment>(c => c.CommentedItemID == id && c.CommentStatus == CommentStatus.Published);
            }

            return(query);
        }
 /// <summary>
 /// Gets the images collection from content.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="fieldName">Name of the field.</param>
 /// <returns>
 /// IQueryable Telerik.Sitefinity.Libraries.Model.Image.
 /// </returns>
 public static List <DocumentModel> GetDocuments(this ContentModel item, string fieldName)
 {
     return(item.DoesFieldExist(fieldName)
         ? item.GetOriginal().GetRelatedItems <Document>(fieldName).Select(x => new DocumentModel(x)).ToList()
         : Enumerable.Empty <DocumentModel>().ToList());
 }
 /// <summary>
 /// Get a temp for <paramref name="cnt"/>, if it exists.
 /// </summary>
 /// <param name="cnt">Content item to get a temp for</param>
 /// <returns>Temp version of <paramref name="cnt"/>, if it exists.</returns>
 /// <exception cref="ArgumentNullException">When <paramref name="cnt"/> is <c>null</c>.</exception>
 public Telerik.Sitefinity.GenericContent.Model.Content GetTemp(Telerik.Sitefinity.GenericContent.Model.Content cnt)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Copy one item to another for the uses of content lifecycle management
 /// </summary>
 /// <param name="source">Item to copy from</param>
 /// <param name="destination">Item to copy to</param>
 public void Copy(Telerik.Sitefinity.GenericContent.Model.Content source, Telerik.Sitefinity.GenericContent.Model.Content destination)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Returns ID of the user that checked out the item, or Guid.Empty if it is not checked out
 /// </summary>
 /// <param name="item">Item to get the user ID it is locked by</param>
 /// <returns>ID of the user that checked out the item or Guid.Empty if the item is not checked out.</returns>
 public Guid GetCheckedOutBy(Telerik.Sitefinity.GenericContent.Model.Content item)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Checks if <paramref name="item"/> is checked out by user with a specified id
 /// </summary>
 /// <param name="item">Item to test</param>
 /// <param name="userId">Id of the user to check if he/she checked out <paramref name="item"/></param>
 /// <returns>True if it was checked out by a user with the specified id, false otherwise</returns>
 public bool IsCheckedOutBy(Telerik.Sitefinity.GenericContent.Model.Content item, Guid userId)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Unpublish a content item in live state.
 /// </summary>
 /// <param name="item">Live item to unpublish.</param>
 /// <returns>Master (draft) state.</returns>
 public Telerik.Sitefinity.GenericContent.Model.Content Unpublish(Telerik.Sitefinity.GenericContent.Model.Content item)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Schedule a content item - to be published from one date to another
 /// </summary>
 /// <param name="item">Content item in master state</param>
 /// <param name="publicationDate">Point in time at which the item will be visible on the public side</param>
 /// <param name="expirationDate">Point in time at which the item will no longer be visible on the public side or null if the item should never expire</param>
 /// <returns>Scheduled content item</returns>
 public Telerik.Sitefinity.GenericContent.Model.Content Schedule(Telerik.Sitefinity.GenericContent.Model.Content item, DateTime publicationDate, DateTime?expirationDate)
 {
     throw new NotImplementedException();
 }