Esempio n. 1
0
        public async Task <Result> DeleteReviewAsync(Guid id, DeleteProductReviewModel model)
        {
            if (CustomerAuthorizationService.CustomerIdIsAuthorized(id))
            {
                return(Result.Forbidden());
            }

            if (await ProductRepository.GetFirstOrDefaultAsync(predicate: c => c.Id == id) == null)
            {
                return(Result.NotFound());
            }

            var review = await ProductReviewRepository.GetFirstOrDefaultAsync(predicate : fp => fp.CustomerId == model.CustomerId && fp.ProductId == id);

            if (review == null)
            {
                return(Result.NotFound());
            }

            ProductReviewRepository.Delete(review);

            await UnitOfWork.SaveChangesAsync();

            return(Result.Success());
        }
Esempio n. 2
0
 public async Task <ActionResult> DeleteReview(Guid id, [FromBody] DeleteProductReviewModel model)
 {
     return(GetResult(await ProductReviewService.DeleteReviewAsync(id, model)));
 }