public bool Edit(int id, int categoryId, string name)
        {
            SubCategory subCategory = this.db.SubCategories.Find(id);

            CategoryInfoServiceModel categoryInfo = this.GetCategoryInfo(categoryId);

            if (subCategory == null ||
                categoryInfo == null ||
                categoryInfo.IsDeleted ||
                (this.NameExists(name) &&
                 subCategory.Name != name))
            {
                return(false);
            }

            subCategory.CategoryId = categoryId;
            subCategory.Name       = name;

            this.db.SaveChanges();

            return(true);
        }
        public bool Create(int categoryId, string name)
        {
            CategoryInfoServiceModel categoryInfo = this.GetCategoryInfo(categoryId);

            if (this.NameExists(name) ||
                categoryInfo == null ||
                categoryInfo.IsDeleted)
            {
                return(false);
            }

            SubCategory subCategory = new SubCategory
            {
                CategoryId = categoryId,
                Name       = name
            };

            this.db.SubCategories.Add(subCategory);
            this.db.SaveChanges();

            return(true);
        }