public int Add(Category newCategory)
        {
            this.categories.Add(newCategory);
            this.categories.SaveChanges();

            return newCategory.Id;
        }
        public Category GenerateCategory()
        {
            var category = new Category()
            {
                Name = "test-category"
            };

            return category;
        }
        public int Add(string name)
        {
            var newCategory = new Category
            {
                Name = name
            };

            this.categoriesRepository.Add(newCategory);
            this.categoriesRepository.SaveChanges();
            return newCategory.Id;
        }
        public int Add(string title, Visibility visibility)
        {
            var newCategory = new Category
            {
                Title = title,
                Visibility = visibility
            };

            this.categories.Add(newCategory);
            this.categories.SaveChanges();

            return newCategory.Id;
        }
        public static MemoryRepository<Category> GetCategoriesRepository()
        {
            var categoriesRepository = new MemoryRepository<Category>();
            for (int i = 0; i < 10; i++)
            {
                var category = new Category
                {
                    Id = i,
                    Name = "category" + i
                };

                categoriesRepository.Add(category);
            }

            return categoriesRepository;
        }
        protected void LinkButtonCreate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.TextBoxCategoryTitle.Text))
            {
                Notifier.AddErrorMessage("Category title is required!");
                return;
            }

            var visibility = this.DropDownVisibilities.SelectedIndex;
            var newCategory = new Category()
            {
                Title = this.TextBoxCategoryTitle.Text,
                Visibility = (Visibility)visibility
            };

            var id = this.Categories.Add(newCategory);

            if (id != 0)
            {
                Notifier.AddSuccessMessage("Category was successfully created!");
                Response.Redirect("~/Admin/EditCategories.aspx");
            }
        }
        private int GetCategoryId(string categoryName)
        {
            var category = this.ForumSystemData.Categories
                               .All()
                               .FirstOrDefault(c => c.Name == categoryName);

            if (category == null)
            {
                category = new Category()
                {
                    Name = categoryName
                };

                this.ForumSystemData.Categories.Add(category);
                this.ForumSystemData.SaveChanges();
            }

            return category.ID;
        }