public ProductResponseDto UpdateProduct(ProductRequestDto productRequestDto, int id)
 {
     CategoryEntity category = db.Categories.SingleOrDefault(category => category.Id == productRequestDto.CategoryId);
     ProductEntity updatedProduct = productRepository.UpdateProduct(new ProductEntity
     {
         Name = productRequestDto.Name,
         Category = category
     },id);
     return new ProductResponseDto
     {
         Id = updatedProduct.Id,
         Name = updatedProduct.Name,
         Category = new CategoryResponseDto
         {
             Id = updatedProduct.Category.Id,
             Name = updatedProduct.Category.Name
         }
     };
 }
        public ProductResponseDto AddProduct(ProductRequestDto productRequestDto)
        {
            CategoryEntity category = db.Categories.SingleOrDefault(category => category.Id == productRequestDto.CategoryId);
            ProductEntity savedProduct = productRepository.AddProduct(new ProductEntity
            {
                Name = productRequestDto.Name,
                Category = category
            });

            return new ProductResponseDto 
            {
                Id = savedProduct.Id,
                Name = savedProduct.Name,
                Category = new CategoryResponseDto
                {
                    Id = savedProduct.Category.Id,
                    Name = savedProduct.Category.Name
                }
            };
        }
 public ProductResponseDto Put([FromBody] ProductRequestDto productRequestDto, int id)
 {
     return(productService.UpdateProduct(productRequestDto, id));
 }
 public ProductResponseDto Post([FromBody] ProductRequestDto productRequestDto)
 {
     return(productService.AddProduct(productRequestDto));
 }