Create webflow model

Open your ASP.NET MVC project and in Models folder create new class file PersonData.cs. In this file create your model which will store your flow data.

public class PersonModel
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Next you should create another file that will have definition of your flow.

using Rosieks.Web.Flow;
using Rosieks.Web.Flow.Fluent;
using Rosieks.Web.Flow.Metadata;

public class PersonFlow : WebflowModel<PersonModel>
{
    public PersonFlow() : base("Person")
    {
        this.RegisterStates(s => s

            // First step that contains two textbox to provide FirstName and LastName
            .Step<ViewState>("Step1") 
                .IsFirstStep()
                .WithView("~/Views/Person/Step1.cshtml")
                .WithTransitions(t => t.Transition("next", "Step2"))
                .WithRoute("PersonWizard", new { step = 1}, "create-person/{step}")

            // Second step that display FirstName and LastName and ask user to confirm data.
            .Step<ViewState>("Step2") 
                .WithView("~/Views/Person/Step2.cshtml")
                .WithTransitions(t => t
                    .Transition("back", "Step1").WithoutValidation()
                    .Transition("next", "Step3"))
                .WithRoute("PersonWizard", new { step = 2})

            // Third/last step - thank you
            .Step<ViewState>("Step3")  
                .WithView("~/Views/Person/Step3.cshtml")
                .WithRoute("PersonWizard", new { step = 3})
                .IsEndStep());

        // Register this webflow in default webflow catalog.
        HashtableWebflowCatalog.Instance.Register(this);
    }
}

Last edited Nov 3, 2011 at 9:32 PM by rosieks, version 3

Comments

No comments yet.