Ejemplo n.º 1
0
        /// <summary>
        /// Adds the term.
        /// </summary>
        /// <param name="term">The term.</param>
        /// <returns>term id.</returns>
        /// <exception cref="System.ArgumentNullException">term is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">term.VocabularyId is less than 0.</exception>
        /// <exception cref="System.ArgumentException">term.Name is empty.</exception>
        public int AddTerm(Term term)
        {
            //Argument Contract
            Requires.NotNull("term", term);
            Requires.PropertyNotNegative("term", "VocabularyId", term.VocabularyId);
            Requires.PropertyNotNullOrEmpty("term", "Name", term.Name);

            if ((term.IsHeirarchical))
            {
                term.TermId = _DataService.AddHeirarchicalTerm(term, UserController.GetCurrentUserInfo().UserID);
            }
            else
            {
                term.TermId = _DataService.AddSimpleTerm(term, UserController.GetCurrentUserInfo().UserID);
            }

            //Clear Cache
            DataCache.RemoveCache(string.Format(_CacheKey, term.VocabularyId));

            return(term.TermId);
        }