Need Help mit User Extension.

Topics: Writing modules
Mar 25, 2012 at 10:25 AM
Edited Mar 25, 2012 at 10:26 AM

Hi,

I do use the WebShop Blog from sfmskywalker  (thanks to him) as base for my Module.

I want extend the process if a user logs on and he has no CustomerPart or AddressPart that this get created for him.

I try to extend the CheckoutController.cs on the SelectAddress Function with following code part:

 

var customer = currentUser.ContentItem.As<CustomerPart>();

if (customer.FirstName == null 

) {  

 

customer.FirstName = "";  

customer.LastName =

" ;   

 

customer.Title = "" ;

 

customer.CreatedAt = System.DateTime.Now;

 

}

But what i Need to call to create the entry inside the database?  If i try like this:

_contentManager.Create(customer.ContentItem);

I get a Error :  SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Thanks for any help

Regards

Markus



 

 

 

 

Developer
Mar 31, 2012 at 2:49 PM
Edited Mar 31, 2012 at 2:49 PM

Hi Markus,

I once had that exception before, and it was because one of the Parts of my content item had a DateTime property which I didn't set to a date higher than 1/1/1753.

I suggest that you have a look at all of the parts attached to the content type of which you're creating the content item, and ensure that all Datetime properties are being set. Also ensure that these properties cascade the update to the underlying Record (I forgot to do so myself, causing the exception on save).

For example, does the line "customer.CreatedAt = DateTime.Now" also set the "CreatedAt" property of the Record object of the CustomerPart?