コード例 #1
0
        /// <summary>
        /// Add a tag to database.
        /// </summary>
        /// <param name="tagName">Body of a tag.</param>
        /// <returns>Returns true if successful.</returns>
        public static bool AddTag(string tagName)
        {
            TagsDataSource db = new TagsDataSource(ConnectionStringHelper.GetActualConnectionString());

            List <Tag> allTags = db.GetAllTags();
            Tag        toAdd   = new Tag();

            // If list is empty skip some steps.
            if (allTags.Count == 0)
            {
                toAdd.Name         = tagName;
                toAdd.CreationDate = System.DateTime.Now;

                db.AddTag(toAdd);

                return(true);
            }

            // If already exists returning false.
            Tag findResult = allTags.Find((temporary) => temporary.Name == tagName);

            if (findResult != null)
            {
                return(false);
            }

            toAdd.Name         = tagName;
            toAdd.CreationDate = System.DateTime.Now;

            db.AddTag(toAdd);

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Add a tag to database.
        /// </summary>
        /// <param name="tagName">Body of a tag.</param>
        /// <returns>Returns true if successful.</returns>
        public static bool AddTag(string tagName)
        {
            TagsDataSource db = new TagsDataSource(ConnectionStringHelper.GetActualConnectionString());

            List<Tag> allTags = db.GetAllTags();
            Tag toAdd = new Tag();

            // If list is empty skip some steps.
            if (allTags.Count == 0)
            {
                toAdd.Name = tagName;
                toAdd.CreationDate = System.DateTime.Now;

                db.AddTag(toAdd);

                return true;
            }

            // If already exists returning false.
            Tag findResult = allTags.Find((temporary) => temporary.Name == tagName);
            if (findResult != null)
            {
                return false;
            }

            toAdd.Name = tagName;
            toAdd.CreationDate = System.DateTime.Now;

            db.AddTag(toAdd);

            return true;
        }
コード例 #3
0
        /// <summary>
        /// Gets all tags.
        /// </summary>
        /// <returns>Tags list.</returns>
        public static List<Tag> GetAllTags()
        {
            TagsDataSource db = new TagsDataSource(ConnectionStringHelper.GetActualConnectionString());

            return db.GetAllTags();
        }
コード例 #4
0
        /// <summary>
        /// Gets all tags.
        /// </summary>
        /// <returns>Tags list.</returns>
        public static List <Tag> GetAllTags()
        {
            TagsDataSource db = new TagsDataSource(ConnectionStringHelper.GetActualConnectionString());

            return(db.GetAllTags());
        }