public async Task <VendorReview> Handle(InsertVendorReviewCommand request, CancellationToken cancellationToken) { //save review int rating = request.Model.AddVendorReview.Rating; if (rating < 1 || rating > 5) { rating = _vendorSettings.DefaultVendorRatingValue; } bool isApproved = !_vendorSettings.VendorReviewsMustBeApproved; var vendorReview = new VendorReview { VendorId = request.Vendor.Id, CustomerId = _workContext.CurrentCustomer.Id, Title = request.Model.AddVendorReview.Title, ReviewText = request.Model.AddVendorReview.ReviewText, Rating = rating, HelpfulYesTotal = 0, HelpfulNoTotal = 0, IsApproved = isApproved, CreatedOnUtc = DateTime.UtcNow, }; await _vendorService.InsertVendorReview(vendorReview); if (!_workContext.CurrentCustomer.HasContributions) { await _customerService.UpdateContributions(_workContext.CurrentCustomer); } //update vendor totals await _vendorService.UpdateVendorReviewTotals(request.Vendor); //notify store owner if (_vendorSettings.NotifyVendorAboutNewVendorReviews) { await _messageProviderService.SendVendorReviewMessage(vendorReview, request.Store, _languageSettings.DefaultAdminLanguageId); } return(vendorReview); }