I’m trying to create a shipment and move it to processing state using this code:
_eventBroker.Subscribe<SalesOrderConfirmed>(async x =>
{
var shipment = await _shipmentManager.Create(x.Item.SystemId, new CreateShipmentArgs
{
Rows = x.Item.Rows.Where(salesOrderRow => salesOrderRow.OrderRowType == OrderRowType.Product)
.Select(salesOrderRow => new ProductToShipRow
{
Quantity = salesOrderRow.Quantity,
ArticleNumber = salesOrderRow.ArticleNumber
}).ToList(),
ShippingMethod = x.Item.ShippingInfo.First().ShippingOption.OptionId,
Address = x.Item.ShippingInfo.First().ShippingAddress,
});
using (_securityContextService.ActAsSystem())
{
_shipmentService.Create(shipment);
}
var stateTransitionResult1 = _stateTransitionsService.SetState<Sales.Shipment>(shipment.SystemId, ShipmentState.Processing);
});
But i get this strange AutoMapper error in the log and I can’t figure out what’s wrong. It’s complaining about FirstName but from what I can see there’s nothing strange about FirstName on the ShippingInfo.First().ShippingAddress that I provide as CreateShipmentArgs.Address.
Any ideas?
2023-09-11 17:16:21.4522 [App:01] [ERROR] [.NET ThreadPool Worker] Litium.Application.Events.EventBrokerImpl - Error mapping types.
Mapping types:
ShipmentEntity → Shipment
Litium.Application.Sales.Data.ShipmentEntity → Litium.Sales.ShipmentType Map configuration:
ShipmentEntity → Shipment
Litium.Application.Sales.Data.ShipmentEntity → Litium.Sales.ShipmentDestination Member:
ReceiverAddress
AutoMapper.AutoMapperMappingException: Error mapping types.Mapping types:
ShipmentEntity → Shipment
Litium.Application.Sales.Data.ShipmentEntity → Litium.Sales.ShipmentType Map configuration:
ShipmentEntity → Shipment
Litium.Application.Sales.Data.ShipmentEntity → Litium.Sales.ShipmentDestination Member:
ReceiverAddress—> AutoMapper.AutoMapperMappingException: Error mapping types.
Mapping types:
AddressEntity → Address
Litium.Application.Sales.Data.AddressEntity → Litium.Sales.AddressType Map configuration:
AddressEntity → Address
Litium.Application.Sales.Data.AddressEntity → Litium.Sales.AddressDestination Member:
FirstName—> System.NotSupportedException: Object is read only.
at Litium.ComponentModel.ObjectBase.ThrowIfReadOnly()
at Litium.ComponentModel.ReadOnlyExtensions.ThrowIfReadOnly[T](ObjectBase self, T item)
at Litium.Sales.Address.set_FirstName(String value)
at lambda_method5614(Closure , ShipmentEntity , Shipment , ResolutionContext )
— End of inner exception stack trace —
at lambda_method5614(Closure , ShipmentEntity , Shipment , ResolutionContext )
— End of inner exception stack trace —
at lambda_method5614(Closure , ShipmentEntity , Shipment , ResolutionContext )
at lambda_method5615(Closure , Object , Object , ResolutionContext )
at Litium.Runtime.AutoMapper.AutoMapperExtensions.MapFrom[TResult](TResult target, Object source)
at Litium.Application.Data.Batching.BatchDataProcessor2.<>c__DisplayClass16_0.<Add>b__0() at Litium.Application.Data.Batching.BatchDataImpl.Commit() at Litium.Application.Sales.ShipmentServiceImpl.Create(Shipment shipment) at Litium.Accelerator.StateTransitions.SalesOrderEventListener.<Litium.Runtime.IAsyncAutostart.StartAsync>b__8_1(SalesOrderConfirmed x) in C:\Repos\SoftubeLitium8\Src\Litium.Accelerator\StateTransitions\SalesOrderEventListener.cs:line 66 at Litium.Application.Events.EventBrokerImpl.<>c__DisplayClass11_1
1.b__4()
at Litium.Application.Common.FifoExecution.WorkItem.Execute()
at Litium.Application.Common.FifoExecution.ProcessQueuedItems(Object ignored)
Litium version: 8.10.0