+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Fluent API Form Examples?

Fluent API Form Examples?

11 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    18 Apr 2011
    Link to this post
    Could you give a few examples on how to use the Fluent API with forms?

    Queries needed:

     - List of form names
     - List of form entries for a particular form

    Thanks,

    Michael Snyder
    ConnectionsAcademy.com
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    22 Apr 2011
    Link to this post
    Hi ,

    You have to use the standard API to get these results.

                FormsManager manager = FormsManager.GetManager();
                var forms = manager.GetForms();
                foreach (FormDescription d in forms)
                {
                     var title = d.Title;
                      var name = d.Name;
                   
                }
    To get the response of a form you can use

    public IEnumerable GetFormEntries(Type entryType, string filter, string orderBy, int skip, int take, ref int? count)


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    20 Jun 2011
    Link to this post
    Hi,

    How do I add a value using Fluent API to the Form I created in CMS?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    20 Jun 2011
    Link to this post
    Hi Zubair,

    Here is the programmatic way to add a new entry to a form

    IManager manager;
    manager = FormsManager.GetManager(providerName);
     
    using (var fluent = App.WorkWith())
    {
        var facade = fluent.Forms().Form(formName);
        facade.Do(fd =>
        {
            fd.FormEntriesSeed++;
            entry.Item.ReferralCode = fd.FormEntriesSeed.ToString();
        });
     
    }
     
    entry.Item.SubmittedOn = DateTime.UtcNow;
    entry.Item.UserId = SecurityManager.GetCurrentUser().UserId;
    this.SetEntryIpAddress(entry.Item);
    manager.SaveChanges();
    ServiceUtility.DisableCache();


    Regards,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  5. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    20 Jun 2011
    Link to this post
    Hi,

    This is incomplete code and it breaks, can you please include full code with namespaces and also tell me how to add value for each form field?

    Thanks,
  6. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    21 Jun 2011
    Link to this post
    Hi,

    Any news?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    21 Jun 2011
    Link to this post
    Hi Zubair,

    Have you specified the form name for which you want to add a new entry? You can get a refernce to the classes through Visual Studio Intellisense. It should shows you the missing reference in your class.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    21 Jun 2011
    Link to this post
    I know I can add a FormName but I cant find out the how the entry will look like, anyway I will look at this post to do the same.
  9. Brett Winklesky
    Brett Winklesky avatar
    6 posts
    Registered:
    10 Dec 2009
    27 Jun 2011
    Link to this post
    @Ivan

    In your code posted on June 20th you are adding the "entry" data.  Where and how are you setting this up?

    entry.Item.SubmittedOn = DateTime.UtcNow;
    entry.Item.UserId = SecurityManager.GetCurrentUser().UserId;
    this.SetEntryIpAddress(entry.Item);
    manager.SaveChanges();
    ServiceUtility.DisableCache();

    I have tried to add a form entry using the sample code and it doesn't work on my end.  Do you guys have a full sample in the SDK? 

    Brett
  10. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    27 Jun 2011
    Link to this post
    @Brett,

    I got this to work with the help of this post, though I changed it from extension method to a 'normal' method

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/how-to-use-createformentry.aspx#1567645

    Telerik/Sitefinity team isn't helping :(
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    28 Jun 2011
    Link to this post
    Hello,

    There is also FormEntriesFacade which could be used to get IQueryable<FormEntry>

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

11 posts, 0 answered