示例#1
0
        public static WeightedTagList GetOrInsertTags(string tagString, bool isAdministrator)
        {
            List <string> rawTags = TagHelper.DistillTagInput(tagString, isAdministrator);

            WeightedTagList tags    = new WeightedTagList();
            TagCollection   newTags = new TagCollection();

            foreach (string tagIdentifier in rawTags)
            {
                //TODO: GJ: get from cache
                Tag tag = Tag.FetchTagByIdentifier(tagIdentifier);

                if (tag == null)
                {
                    tag = new Tag();
                    tag.TagIdentifier = tagIdentifier;
                    newTags.Add(tag);
                }
                else
                {
                    tags.Add(new WeightedTag(tag.TagID, tag.TagIdentifier, 1));
                }
            }

            // newTags.BatchSave(); //TODO: GJ: does BatchSave update identity colums after save?

            foreach (Tag newTag in newTags)
            {
                newTag.Save(); //TODO: GJ: does BatchSave update identity colums after save?
                tags.Add(new WeightedTag(newTag.TagID, newTag.TagIdentifier, 1));
            }

            return(tags);
        }
示例#2
0
 public void DistillTagInputTest(string rawTagInput, bool isAdministrator, string[] expected)
 {
     string[] distilledTags = TagHelper.DistillTagInput(rawTagInput, isAdministrator).ToArray();
     ArrayAssert.AreEqual(expected, distilledTags);
 }