Create a news item with the Fluent API

Use the code example below to create a news item and to set its Title and Content with the Fluent API. In the example below, you perform the following:

  1. Set the properties of the news item by calling the Do method of the facade.
  2. Set the state of the news item to published.
  3. Save the changes to the facade.

Create a news item with the Fluent API

C#
var masterNewsId = Guid.NewGuid();
App.WorkWith().NewsItem().CreateNew(masterNewsId)
.Do(newsItem =>
{
   newsItem.Title = title;
   newsItem.Content = content;
})
.Publish()
.SaveChanges();
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?