How Change Content Page Template Via C# programming API

Hi Guys,

I have some issue in my Umbraco Website. I have two nodes of same item but both items having different template.

Example Like

  1. Product ( template = product-item)
  2. Store Product ( template = product-item)

Now I want to change the product template to pproduct-item. There are 10000 thousand sub node under this so it’s not possible do it manual, bcoz its also having child that are using different template too.

IContent mynode = ApplicationContext.Current.Services.ContentService.GetById(item.Id);
mynode.ContentType.DefaultTemplate.Content = "sometemplate";
ApplicationContext.Current.Services.ContentService.SaveAndPublishWithStatus(mynode,0);

Also how I can add images via API in media picker at the node.

I was tried to change template via content service but it’s not working. So please Guys if anyone can help me.. I really appreciate it .

Thanks
Waiting for reply


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/73366-how-change-content-page-template-via-c-programming-api