/// <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(); } }
/// <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); }
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); } }
private static void MakeFullCategoryName(QuestionCategory rootCategory) { MakeFullCategoryName(rootCategory, rootCategory); }