/// <summary>
        /// Insert a new subcategory
        /// </summary>
        /// <param name="subcategory"></param>
        public async Task Add(Subcategory subcategory)
        {
            subcategory.Enabled = true;
            var nameExists = (await _repository.GetSubcategoryByName(subcategory.Name, subcategory.CategoryId)) != null;

            if (!nameExists)
            {
                await _repository.Insert(subcategory);
            }
            else
            {
                throw new AlreadyExistsException($"Already exists a subcategory {subcategory.Name} in this category");
            }
        }
        public void Insert(Subcategory subcategory)
        {
            var exists = _repository.GetAll(subcategory.Name, subcategory.CategoryId).Count() > 0;

            subcategory.Enabled = true;
            subcategory.CanEdit = true;

            if (!exists)
            {
                _repository.Insert(subcategory);
            }
            else
            {
                throw new ObjectAlreadyExistsException($"Already exists a subcategory with the name {subcategory.Name}");
            }
        }