Skip to content

Commit

Permalink
Fixed bug with EF duplicate PK when order update if any of shipments …
Browse files Browse the repository at this point in the history
…have a new shipment item
  • Loading branch information
tatarincev committed Sep 21, 2018
1 parent ecccede commit 943bb97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions VirtoCommerce.OrderModule.Data/Model/ShipmentItemEntity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Omu.ValueInjecter;
Expand Down Expand Up @@ -43,7 +43,11 @@ public virtual ShipmentItemEntity FromModel(ShipmentItem shipmentItem, PrimaryKe

pkMap.AddPair(shipmentItem, this);
this.InjectFrom(shipmentItem);
ModelLineItem = shipmentItem.LineItem;
//Store ModelLineItem for future linking with the order line item only for new objects otherwise we will get error when saving
if (shipmentItem.LineItem != null && shipmentItem.LineItem.IsTransient())
{
ModelLineItem = shipmentItem.LineItem;
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public OrderModuleController(ICustomerOrderService customerOrderService, ICustom
_notificationManager = notificationManager;
_notificationTemplateResolver = notificationTemplateResolver;
_changeLogService = changeLogService;
_totalsCalculator = totalsCalculator;
}

/// <summary>
Expand Down

0 comments on commit 943bb97

Please sign in to comment.