Skip to content

No set value for Recipients and LineItems #5

@gregobrien1613

Description

@gregobrien1613

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);
}; 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions