/// <summary>
 /// Adds the specified category.
 /// </summary>
 /// <param name="category">The category.</param>
 public static void Add(QuestionCategory category)
 {
     using (var context = new Entities())
     {
         context.QuestionCategories.Add(category);
         context.SaveChanges();
     }
 }
예제 #2
0
        /// <summary>
        /// Creates the category.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="parentId">The parent id.</param>
        public void CreateCategory(string name, int? parentId)
        {
            var category = new QuestionCategory()
            {
                Name = name,
                ParentCategoryId = parentId
            };

            QuestionCategoryRepository.Add(category);
        }
예제 #3
0
        private static void MakeFullCategoryName(QuestionCategory rootCategory, QuestionCategory childCategory)
        {
            var parentCategory = QuestionCategoryRepository.GetById(childCategory.ParentCategoryId.Value);

            rootCategory.Name = parentCategory.Name + "/" + rootCategory.Name;

            if (parentCategory.ParentCategoryId != null)
            {
                MakeFullCategoryName(rootCategory, parentCategory);
            }
        }
예제 #4
0
 private static void MakeFullCategoryName(QuestionCategory rootCategory)
 {
     MakeFullCategoryName(rootCategory, rootCategory);
 }