Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
60 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />
Then we get SingleAlternativeAnswer from the selected alternative and add it to AnswerCollectionAnswer.<br />
SingleAlternativeAnswer saa =<br />
SingleAlternativeAnswer( alternative );<br />
answers.Add( saa );<br />
Create a contest submission for the user.<br />
Submissin submission =<br />
new Submission(contest, answers, user, "John", "Doe", "Address", "Zip",<br />
"City", "Email");<br />
At this point the submission only exists in memory. To commit it to the database we use the AddSubmission method in<br />
the ContestHandler class.<br />
ContestHandler.AddSubmission( submission );<br />
Note: The contest system doesn’t allow for more than one submission per logged in user and will throw an exception if<br />
this occurs. You can check for duplicate submissions by:<br />
IUser user =<br />
(StarCommunity.Core.Modules.Security.IUser)StarCommunitySystem.<br />
CurrentContext.DefaultSecurity.CurrentUser;<br />
bool submitted =<br />
ContestHandler.GetSubmission(user, contest) != null;<br />
2.15.4 Get winners<br />
Winners are typically selected by an administrator in the administration interface. However, you often want to get the<br />
winners for a contest for displaying them on your community.<br />
Import Necessary Namespaces<br />
First import the necessary namespaces that will be used to manage contests. The namespace<br />
StarCommunity.Modules.Contest is described by clicking on its name. Make sure you add the assemblies as a reference,<br />
mentioned in section 1.1.1.<br />
using StarCommunity.Modules.Contest;<br />
First we need to get the Contest. This is done via the ContestHandler class.<br />
Contest contest = ContestHandler.GetContest( 1234 );<br />
© <strong>EPiServer</strong> AB