Skip to content

Commit f277f3a

Browse files
committed
Fix for #130 - now we set the current time if it is not specified to prevent DateTime conversion issues in SQL (datetime is used instead of datetime2)
1 parent 146855c commit f277f3a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Nop.Plugin.Api/Controllers/CustomersController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ public IActionResult CreateCustomer([ModelBinder(typeof(JsonModelBinder<Customer
250250

251251
foreach (var address in customerDelta.Dto.CustomerAddresses)
252252
{
253+
// we need to explicitly set the date as if it is not specified
254+
// it will default to 01/01/0001 which is not supported by SQL Server and throws and exception
255+
if (address.CreatedOnUtc == null)
256+
{
257+
address.CreatedOnUtc = DateTime.UtcNow;
258+
}
253259
newCustomer.Addresses.Add(address.ToEntity());
254260
}
255261

0 commit comments

Comments
 (0)