Exemple #1
0
        public async Task <Review> Insert(long productId, ReviewPut reviewPut)
        {
            Product product = await _products.GetById(productId);

            if (product == null)
            {
                throw new Exception("PRODUTO não encontrado");
            }

            Customer customer = await _customers.GetById(reviewPut.CustomerId);

            if (customer == null)
            {
                throw new Exception("CLIENTE não encontrado");
            }

            var review = reviewPut.CreateDomain(customer);
            await _products.InsertReview(product, review);

            return(review);
        }
        public async Task <IActionResult> Put([FromRoute] long id, [FromBody] ReviewPut reviewPut)
        {
            Review review = await _productReviewService.Insert(productId : id, reviewPut);

            return(Ok(new Response <long>(review.Id)));
        }