workflow

Posted by Community Admin on 03-Aug-2018 08:14

workflow

All Replies

Posted by Community Admin on 02-Sep-2011 00:00

Can you please provide me some code for changing a product in the products sample and checking it in and out using C#?

I want to query only published products

I want to check out a product and edit it and then check it in

I want to publish a product

Cheers!

Posted by Community Admin on 02-Sep-2011 00:00

Hi Brian,

You can take a look in the ProductsModule sample.

To query for published products:

var manager = ProductsManager.GetManager();
var products = manager.GetProducts().Where(x => x.Status == ContentLifecycleStatus.Live).ToList();

You could use the Fluent API I guess to get a product and checkout, do the changes and publish it again. But I'm not sure actually.

Regards,
Daniel

Posted by Community Admin on 05-Sep-2011 00:00

Thank you Daniel for your response. 

Can someone at Telerik please comment on this. I really need to find out how to properly check in and out and publish custom module data like products using C#.

Posted by Community Admin on 07-Sep-2011 00:00

Hello Brian Crosby,

Like Daniel properly pointed out, you'll need to work with Productsmanager. ProductsManager inherits from ContentManagerBase, so basically what you have for a news item:

NewsManager manager = NewsManager.GetManager();
    NewsItem item = manager.GetNewsItems()
                        .Where(t => t.Title == newsTitle)
                        .Where(t => t.Status == ContentLifecycleStatus.Live)
                        .Single();
 
    item = manager.GetMaster(item);    // make sure we are working with master
    NewsItem temp = manager.CheckOut(item); // work on a temp
    //
    temp.Content = newContent;
    //
    item = manager.CheckIn(temp);
    manager.RecompileItemUrls<NewsItem>(item);
    manager.Publish(item);
    manager.SaveChanges();
would be identical when calling ProductsManager.GetManager();

Greetings,
Boyan Barnev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 07-Sep-2011 00:00

Hello Brian Crosby,

Just a quick follow-up, please find below a sample code for achieveing the same functionality with a products item:

ProductsManager manager = ProductsManager.GetManager();
           ProductItem item = manager.GetProducts()
                                .Where(t => t.Title == "title")
                                .Where(t => t.Status == ContentLifecycleStatus.Live)
                                .Single();
 
           item = manager.Lifecycle.GetMaster(item) as ProductItem; // make sure we are working with master
           var temp = manager.Lifecycle.CheckOut(item); // work on a temp
            
            //
            item = manager.Lifecycle.CheckIn(temp) as ProductItem;
            manager.RecompileItemUrls<ProductItem>(item);
            manager.Lifecycle.Publish(item);
            manager.SaveChanges();


Best wishes,
Boyan Barnev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

This thread is closed