예제 #1
0
        public Item CreateNewsArticle(NewsArticle newsArticle)
        {
            var newItem = ParentItem.Add(newsArticle.Title, Template);

            _iFieldUpdater.AddFieldsToItem(newItem, newsArticle);

            return newItem;
        }
예제 #2
0
        public void DeleteNewsArticle(NewsArticle newsArticle)
        {
            var id = _iSitecoreUtilities.ParseId(newsArticle.Id);

            var item = _iNewsReader.GetNewsItem(id);

            item.Delete();
        }
예제 #3
0
        public void UpdateNewsArticle(NewsArticle newsArticle)
        {
            var id = _iSitecoreUtilities.ParseId(newsArticle.Id);

            if (!id.IsNull)
            {
                var item = _iNewsReader.GetNewsItem(id);

                _iFieldUpdater.AddFieldsToItem(item, newsArticle);
            }
        }
예제 #4
0
        public bool NewsAticleExists(NewsArticle newsArticle)
        {
            var exists = false;

            if (newsArticle.Id != null)
            {
                var id = _iSitecoreUtilities.ParseId(newsArticle.Id);
                exists = Sitecore.Data.Database.GetDatabase("master").GetItem(id) != null;
            }

            return exists;
        }
예제 #5
0
        public NewsArticle GetNewsArticle(Item item)
        {
            var newsArticle = new NewsArticle();

            var dateField = (Sitecore.Data.Fields.DateField)item.Fields["Date"];

            newsArticle.Title = item["Title"];
            newsArticle.Body = item["Body"];
            newsArticle.Date = dateField.DateTime;
            newsArticle.itemId = item.ID.ToString();
            newsArticle.Id = item.ID.ToString();
            newsArticle.Url = item.Paths.ContentPath;

            return newsArticle;
        }