Powerpoint and Code from the Sitefinity 4.0 BETA Webinar

Powerpoint and Code from the Sitefinity 4.0 BETA Webinar

July 30, 2010 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

I’m still working on posting the Sitefinity 4.0 BETA webinar video. Due to technical issues encountered early into the webinar I lost the Gotomeeting recording.  We have backup recordings, but these recordings contain Ivan Osmak & I’s individual local recordings.  These two local recordings need combined into a single video.  It’s going to take me some time to get this video processed.  Be patient with me.

In the meantime, I’ve attached our Powerpoint slides to this blog post. 

Telerik Q2 2010 - What's New in the Sitefinity 4.0 BETA

Sitefinity 4.0 - Fluent API presentation

I’ve also posted Ivan’s code samples below:

~/Webinar.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Webinar.aspx.cs" Inherits="SitefinityWebApp.Webinar" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
     
        <h1>
            Fluent API - webinar examples
        </h1>
 
        <h3>
            Introductory example
        </h3>
 
        <p>
            <asp:Label ID="newsItemTitleLabel" runat="server" Text="News item title:"></asp:Label>
            <asp:TextBox ID="newsItemTitle" runat="server"></asp:TextBox>
            <asp:Button ID="createNewsItem" runat="server" Text="Create news item" OnClick="createNewsItem_Click" />
        </p>
 
        <h3>Named transactions and "using() {}" syntax</h3>
        <p>
            <p>
                Create 10 content items and 20 event items.
                <asp:Button ID="createContentItemsAndEvents" runat="server" Text="Create" OnClick="createContentItemsAndEvents_Click" />
            </p>
        </p>
 
        <h3>Child facades</h3>
        <p>
            <p>
                Create a new blog and then create a blog post in it.
                <asp:Button ID="createABlogAndBlogPost" runat="server" Text="Create" OnClick="createABlogAndBlogPost_Click" />
            </p>
        </p>
 
        <h3>Three random examples</h3>
        <p>
            <p>
                Create a page:
                <asp:Button ID="createAPage" runat="server" Text="Create" OnClick="createAPage_Click" />
            </p>
        </p>
 
        <p>
            <p>
                Add dynamic field to an existing NewsItem type:
                <asp:Button ID="addDynamicField" runat="server" Text="Add dynamic field" OnClick="addDynamicField_Click" />
            </p>
        </p>
 
        <p>
            <p>
                Create a completely new dynamic type:
                <asp:Button ID="createDynamicType" runat="server" Text="createDynamicType" OnClick="createDynamicType_Click" />
            </p>
        </p>
 
    </form>
</body>
</html>

~/Webinar.aspx.cs

using System;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Fluent.Pages;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.Web;
using Telerik.Sitefinity.Modules.Pages;
using System.Linq;
using Telerik.Sitefinity.News.Model;
using Telerik.Sitefinity.Metadata.Model;
 
namespace SitefinityWebApp
{
    public partial class Webinar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void createNewsItem_Click(object sender, EventArgs e)
        {
            App.Prepare()
                    .SetPagesProvider("Mypages")
                    .SetTransactionName("Tran1")
                .WorkWith()
               .NewsItem()
               .CreateNew()
               .Do(ni =>
                   {
                       ni.Title = this.newsItemTitle.Text;
                       ni.Description = "Some description";
                   })
               .SaveChanges();
        }
 
        protected void createContentItemsAndEvents_Click(object sender, EventArgs e)
        {
            using (var fluent = App.WorkWith())
            {
                // create 10 content items
                for (int i = 0; i < 10; i++)
                {
                    fluent.ContentItem()
                          .CreateNew()
                          .Do(ci =>
                              {
                                  ci.Title = "Content item " + i.ToString();
                                  ci.Author = "Ivan";
                              });
                }
 
                // create 20 events
                for (int i = 0; i < 20; i++)
                {
                    fluent.Event()
                          .CreateNew()
                          .Do(ev =>
                              {
                                  ev.Title = "Event " + i.ToString();
                                  ev.EventStart = DateTime.Now;
                              });
                }
            }
            // all items will be committed automatically in one transaction upon the exit of the using block
        }
 
        protected void createABlogAndBlogPost_Click(object sender, EventArgs e)
        {
            App.WorkWith()
               .Blog()
               .CreateNew()
               .Do(b =>
                   {
                       b.Title = "Our test blog";
                       b.UrlName = "our-test-blog";
                   })
               .BlogPost()
                    .CreateNew()
                    .Do(bp => bp.Title = "First blog post")
                    .Done()
               .Do(b => b.Description = "Forgot to add the blog description")
               .SaveChanges();
        }
 
 
        protected void createAPage_Click(object sender, EventArgs e)
        {
            App.WorkWith()
               .Page()
               .CreateNewStandardPage(PageLocation.Frontend)
               .Do(pn =>
                   {
                       pn.Title = "My Page";
                       pn.UrlName = "my-page";
                   })
               .SaveChanges();
 
            SiteMapBase.Cache.Flush();
        }
 
        protected void addDynamicField_Click(object sender, EventArgs e)
        {
            App.WorkWith()
               .DynamicData()
               .Type(typeof(NewsItem))
               .Field()
                    .TryCreateNew("ResearcherName", typeof(string))
                    .SaveChanges(true);
        }
 
        protected void createDynamicType_Click(object sender, EventArgs e)
        {
            App.WorkWith()
               .DynamicData()
               .Type()
               .CreateNew("ContactInfo", "Telerik.Sitefinity.DynamicTypes.Model")
               .Do(dt => dt.DatabaseInheritance = DatabaseInheritanceType.vertical)
               .Field()
                    .CreateNew("FirstName", typeof(string))
                    .Done()
               .Field()
                    .CreateNew("LastName", typeof(string))
                    .Done()
               .Field()
                    .CreateNew("Age", typeof(int))
                    .Done()
               .SaveChanges(true);
        }
 
    }
}

This code uses features that are found in the upcoming BETA.  Consequently, it’s unlikely this code will work with the CTP release of Sitefinity 4.0.  If you’re interested, you’ll get a chance to play with the Fluent API next week.

progress-logo

The Progress Guys

View all posts from The Progress Guys on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments
Comments are disabled in preview mode.
Topics
 
 
Latest Stories in
Your Inbox
Subscribe
More From Progress
d12fcc0bdb669b804e7f71198c9619a7
5 Questions Automakers Should Ask to Improve Asset Uptime
Download Whitepaper
 
SF_MQ_WCM
2018 Gartner Magic Quadrant Web Content Management (WCM)
Download Whitepaper
 
What-Serverless-Means-For-Enterprice-Apps-Kinvey
What Serverless Means for Enterprise Apps
Watch Webinar