When trying to loop through my order I am struggling to add LineItems because I get this error when trying to construct the new order that will go into ShippingEasy:
(82,17): error CS0200: Property or indexer 'Recipient.LineItems' cannot be assigned to -- it is read only
Here is some code.
var client = new Client(apiKey, apiSecret, baseUrl);
// Iterate through the list of OrderData and create orders
foreach (var orderData in listData)
{
// Create an order and assign the list of recipients
var order = new Order
{
ExternalOrderIdentifier = orderData.ExternalOrderIdentifier,
OrderedAt = orderData.OrderedAt,
Recipients =
{
new Recipient
{
FirstName = orderData.Recipients[0].FirstName,
LastName = orderData.Recipients[0].LastName,
Address = orderData.Recipients[0].Address,
City = orderData.Recipients[0].City,
State = orderData.Recipients[0].State,
LineItems = orderData.Recipients[0].LineItems.Select(item => new LineItem
{
ItemName = item.ItemName,
Quantity = item.Quantity
}).ToList()
}
}
};
// Assign the first recipient to the order
// Create orders using the Order object
var result = client.CreateOrder(storeApiKey, order);
HttpResponse response = result.HttpResponse;
Console.WriteLine(response);
};
When trying to loop through my order I am struggling to add LineItems because I get this error when trying to construct the new order that will go into ShippingEasy:
(82,17): error CS0200: Property or indexer 'Recipient.LineItems' cannot be assigned to -- it is read only
Here is some code.
var client = new Client(apiKey, apiSecret, baseUrl);
// Iterate through the list of OrderData and create orders
foreach (var orderData in listData)
{
// Create an order and assign the list of recipients
var order = new Order
{
ExternalOrderIdentifier = orderData.ExternalOrderIdentifier,
OrderedAt = orderData.OrderedAt,
Recipients =
{
new Recipient
{
FirstName = orderData.Recipients[0].FirstName,
LastName = orderData.Recipients[0].LastName,
Address = orderData.Recipients[0].Address,
City = orderData.Recipients[0].City,
State = orderData.Recipients[0].State,
LineItems = orderData.Recipients[0].LineItems.Select(item => new LineItem
{
ItemName = item.ItemName,
Quantity = item.Quantity
}).ToList()
}
}
};
// Assign the first recipient to the order