// PUT api/categories/id
        public IHttpActionResult PutCategory(int id, [FromBody] CategoryProductModelView category)
        {
            var catOld = categoryService.GetById(id);

            if (catOld == null)
            {
                return(NotFound());
            }

            if (category == null)
            {
                return(BadRequest());
            }

            var newCat = new CategoryProductDTO
            {
                Id           = id,
                CategoryName = category.CategoryName,
                Product      = mapper.Map <ICollection <ProductModelView>, ICollection <ProductDTO> >(category.Product)
            };

            categoryService.Update(newCat);

            return(Ok(new { Message = $"A category {category.CategoryName} has updated" }));
        }
        // POST api/categories/id
        public IHttpActionResult PostCategory([FromBody] CategoryProductModelView category)
        {
            if (!ModelState.IsValid || category == null)
            {
                return(BadRequest());
            }

            var model = new CategoryProductDTO
            {
                CategoryName = category.CategoryName,
                Product      = mapper.Map <ICollection <ProductModelView>, ICollection <ProductDTO> >(category.Product)
            };

            categoryService.Create(model);

            return(Ok(new { Message = $"The new category {category.CategoryName} has created" }));
        }