public async Task <IActionResult> UpdateProductCategories(int id, [FromBody] ProductCategoryFormDto categoryUpdate)
        {
            var category = await _productRepo.GetProductCategory(id);

            if (category == null)
            {
                return(NotFound(new { error = new string[] { "Category not found" } }));
            }

            if (string.IsNullOrEmpty(categoryUpdate.Name))
            {
                ModelState.AddModelError("error", "Category Name is required");
            }


            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            category.Name = categoryUpdate.Name;

            if (await _productRepo.Save())
            {
                var categoryToReturn = _mapper.Map <ProductCategoryInfoDto>(category);

                return(Ok(categoryToReturn));
            }

            return(BadRequest(new { error = new string[] { "Cannot update category" } }));
        }
        public async Task <IActionResult> CreateProductCategories([FromBody] ProductCategoryFormDto newCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ProductCategory category = new ProductCategory
            {
                Name = newCategory.Name
            };

            _productRepo.Add(category);

            if (await _productRepo.Save())
            {
                return(Ok(category));
            }

            return(BadRequest(new { error = new string[] { "Product Category cannot be saved" } }));
        }