Example #1
0
        public Identity Save(Tag tag)
        {
            if (tag == null || string.IsNullOrEmpty(tag.Name))
            {
                return null;
            }

            Tag existingTag = this.GetTagByName(tag.Name);
            if (existingTag != null)
            {
                return TagStore.Save(tag, existingTag.GetIdentity());
            }

            return TagStore.Save(tag);
        }
Example #2
0
 public void Delete(Tag tag)
 {
     TagStore.Delete(tag);
 }
Example #3
0
        public PageDataCollection GetPagesByTag(Tag tag, PageReference rootPageReference)
        {
            if (tag == null || tag.PermanentLinks == null)
            {
                return null;
            }

            IList<PageReference> descendantPageReferences = DataFactory.Instance.GetDescendents(rootPageReference);

            if (descendantPageReferences == null || descendantPageReferences.Count < 1)
            {
                return null;
            }

            var pages = new PageDataCollection();

            foreach (Guid pageGuid in tag.PermanentLinks)
            {
                var pageReference = TagsHelper.GetPageReference(pageGuid);

                if (descendantPageReferences.FirstOrDefault(p => p.ID == pageReference.ID) != null)
                {
                    pages.Add(DataFactory.Instance.GetPage(pageReference));
                }
            }

            return pages;
        }
Example #4
0
        public PageDataCollection GetPagesByTag(Tag tag)
        {
            if (tag == null)
            {
                return null;
            }

            var pageLinks = new List<Guid>();

            if (tag.PermanentLinks == null)
            {
                var tempTerm = this._tagService.GetTagByName(tag.Name);

                if (tempTerm != null)
                {
                    pageLinks = tempTerm.PermanentLinks.ToList();
                }
            }
            else
            {
                pageLinks = tag.PermanentLinks.ToList();
            }

            var pages = new PageDataCollection();

            foreach (Guid pageGuid in pageLinks)
            {
                pages.Add(DataFactory.Instance.GetPage(TagsHelper.GetPageReference(pageGuid)));
            }

            return pages;
        }
Example #5
0
 public Identity Save(Tag tag)
 {
     return _tagRepository.Save(tag);
 }
 private static object ToAutoComplete(Tag tag)
 {
     return new { name = tag.Name, id = tag.Name };
 }
Example #7
0
        public Tag Save(Guid pageGuid, string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return null;
            }

            Tag tag = this.GetTagByName(name);

            if (tag == null)
            {
                tag = new Tag
                {
                    Count = 1,
                    Name = name,
                    PermanentLinks = new List<Guid>() { pageGuid }
                };
            }
            else
            {
                if (tag.PermanentLinks == null)
                {
                    tag.PermanentLinks = new List<Guid>() { pageGuid };
                    tag.Count = tag.Count + 1;
                }
                else
                {
                    if (!tag.PermanentLinks.Contains(pageGuid))
                    {
                        tag.PermanentLinks.Add(pageGuid);

                        tag.Count = tag.Count + 1;
                    }
                }
            }

            this.Save(tag);

            return tag;
        }