public void DeleteLibraryQuestionCategory(Int16 categoryId) { var existingItem = LibrariesDal.GetLibraryQuestionCategoryById(this.AccessTokenId, categoryId); if (existingItem == null) { throw new VLException(SR.GetString(SR.There_is_no_item_with_id, "LibraryQuestionCategory", categoryId)); } //Can we delete the LibraryQuestinCategory? if (existingItem.IsBuiltIn) { throw new VLException(SR.GetString(SR.You_cannot_delete_builtin, "LibraryQuestionCategory")); } var _total = LibrariesDal.GetLibraryQuestionsCount(this.AccessTokenId, categoryId); if (_total == 1) { throw new VLException(string.Format("You cannot delete library category '{0}'. There is one question depending on it!", existingItem.Name)); } else if (_total > 1) { throw new VLException(string.Format("You cannot delete library category '{0}'. There are questions depending on it!", existingItem.Name)); } LibrariesDal.DeleteLibraryQuestionCategory(this.AccessTokenId, existingItem.CategoryId); }