Exemple #1
0
        public ActionResult <ProductForHomeDto> LikeProduct(FavoriteForCreationDto favoriteDto)
        {
            var client  = clientService.GetClientById(favoriteDto.ClientId);
            var product = productService.GetProductById(favoriteDto.ProductId);

            if (client == null || product == null)
            {
                return(NotFound());
            }

            var favorite = favoritesService.AddProductToFavorites(new Favorites {
                ProductId = favoriteDto.ProductId, ClientId = favoriteDto.ClientId
            });

            return(CreatedAtRoute("GetProduct", new { productId = product.Id }, favorite));
        }