Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Last active November 2, 2020 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PradeepLoganathan/3817b6b59d6b299c3e3d1bf36d333db2 to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/3817b6b59d6b299c3e3d1bf36d333db2 to your computer and use it in GitHub Desktop.
public async Task AddCustomer(Customer customer)
{
try
{
ItemResponse<Customer> customerResponse = await this._container.CreateItemAsync<Customer>(customer, new PartitionKey(customer.CustomerId));
}
catch (CosmosException ex)
{
Console.WriteLine("Exception occured in AddCustomer: Message body is {0}.\n", ex.Message);
throw;
}
}
public async Task AddOrders(List<Order> orders, string CustomerId)
{
try
{
foreach (var order in orders)
{
ItemResponse<Order> orderResponse = await this._container.CreateItemAsync<Order>(order, new PartitionKey(CustomerId));
}
}
catch (CosmosException ex)
{
Console.WriteLine("Exception occured in AddCustomer: Message body is {0}.\n", ex.Message);
throw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment