From e7727f6b5973e9bc348bb6263a5b119d9ba55d3e Mon Sep 17 00:00:00 2001 From: OlegoO Date: Fri, 19 Mar 2021 09:44:38 +0200 Subject: [PATCH] Fix ReviewStatus Changed Event is empty for WebHook. --- .../Models/ReviewStatusChangeData.cs | 7 +++++-- .../Services/CustomerReviewService.cs | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/VirtoCommerce.CustomerReviews.Core/Models/ReviewStatusChangeData.cs b/src/VirtoCommerce.CustomerReviews.Core/Models/ReviewStatusChangeData.cs index 424b9dd..767b3be 100644 --- a/src/VirtoCommerce.CustomerReviews.Core/Models/ReviewStatusChangeData.cs +++ b/src/VirtoCommerce.CustomerReviews.Core/Models/ReviewStatusChangeData.cs @@ -1,7 +1,10 @@ -namespace VirtoCommerce.CustomerReviews.Core.Models +using VirtoCommerce.Platform.Core.Common; + +namespace VirtoCommerce.CustomerReviews.Core.Models { - public class ReviewStatusChangeData + public class ReviewStatusChangeData : IEntity { + public string Id { get; set; } public string StoreId { get; set; } public string ProductId { get; set; } public CustomerReviewStatus OldStatus { get; set; } diff --git a/src/VirtoCommerce.CustomerReviews.Data/Services/CustomerReviewService.cs b/src/VirtoCommerce.CustomerReviews.Data/Services/CustomerReviewService.cs index 233dd0b..0dba2a1 100644 --- a/src/VirtoCommerce.CustomerReviews.Data/Services/CustomerReviewService.cs +++ b/src/VirtoCommerce.CustomerReviews.Data/Services/CustomerReviewService.cs @@ -46,16 +46,16 @@ public async Task GetByIdsAsync(string[] customerReviewsIds) }); } - public async Task SaveCustomerReviewsAsync(CustomerReview[] customerReviews) + public async Task SaveCustomerReviewsAsync(CustomerReview[] items) { var pkMap = new PrimaryKeyResolvingMap(); var changedEntries = new List>(); using (var repository = _repositoryFactory()) { - - var alreadyExistEntities = await repository.GetByIdsAsync(customerReviews.Where(m => !m.IsTransient()).Select(x => x.Id)); - foreach (var customerReview in customerReviews) + + var alreadyExistEntities = await repository.GetByIdsAsync(items.Where(m => !m.IsTransient()).Select(x => x.Id)); + foreach (var customerReview in items) { var sourceEntity = AbstractTypeFactory.TryCreateInstance().FromModel(customerReview, pkMap); var targetEntity = alreadyExistEntities.FirstOrDefault(x => x.Id == sourceEntity.Id); @@ -131,6 +131,7 @@ private async Task ChangeReviewStatusAsync(string[] ids, CustomerReviewStatus st { reviewStatusChanges.Add(new ReviewStatusChangeData { + Id = customerReviewEntity.Id, ProductId = customerReviewEntity.ProductId, StoreId = customerReviewEntity.StoreId, OldStatus = (CustomerReviewStatus)customerReviewEntity.ReviewStatus, @@ -147,7 +148,7 @@ await _eventPublisher.Publish(new ReviewStatusChangedEvent(reviewStatusChanges.S new GenericChangedEntry(x, EntryState.Modified)))); } } - + protected virtual void ClearCache() {