Skip to content

Commit

Permalink
Merge pull request #13 from VirtoCommerce/fix/VP-7269
Browse files Browse the repository at this point in the history
VP-7269: Fix ReviewStatus Changed Event is empty for WebHook
  • Loading branch information
Vectorfield4 authored Mar 23, 2021
2 parents 234b4b5 + e7727f6 commit 736423a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ public async Task<CustomerReview[]> GetByIdsAsync(string[] customerReviewsIds)
});
}

public async Task SaveCustomerReviewsAsync(CustomerReview[] customerReviews)
public async Task SaveCustomerReviewsAsync(CustomerReview[] items)
{
var pkMap = new PrimaryKeyResolvingMap();
var changedEntries = new List<GenericChangedEntry<CustomerReview>>();

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<CustomerReviewEntity>.TryCreateInstance().FromModel(customerReview, pkMap);
var targetEntity = alreadyExistEntities.FirstOrDefault(x => x.Id == sourceEntity.Id);
Expand Down Expand Up @@ -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,
Expand All @@ -147,7 +148,7 @@ await _eventPublisher.Publish(new ReviewStatusChangedEvent(reviewStatusChanges.S
new GenericChangedEntry<ReviewStatusChangeData>(x, EntryState.Modified))));
}
}


protected virtual void ClearCache()
{
Expand Down

0 comments on commit 736423a

Please sign in to comment.