Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
48 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />
Import Necessary Namespaces<br />
First import the necessary namespaces that will be used to add a club member. The namespaces<br />
StarCommunity.Modules.Club, StarCommunity.Core.Modules.Security and StarCommunity.Core are described by<br />
clicking on their respective names. Make sure you add the assemblies as a reference, mentioned in section 1.1.1.<br />
using StarCommunity.Core;<br />
using StarCommunity.Core.Modules.Security;<br />
using StarCommunity.Modules.Club;<br />
Adding a Member<br />
To add a member we first get the club we want to become member of by its id, and then the user that is to become a<br />
member by its id.<br />
We create a Membership object instance and supply the club and user as arguments to its constructor. When we<br />
create the Membership object instance, the membership will be set to MembershipType.Applied if the club is set to<br />
SecurityStatus.Closed. This means that if we use this default behavior, the membership will have to be applied by an<br />
administrator or the club owner before it is valid. Finally we call the AddMembership method to store the membership<br />
in the database.<br />
//Get the club by id<br />
Club club = ClubHandler.GetClub(1234);<br />
//Get the new member by id<br />
IUser user = (IUser)StarCommunitySystem.<br />
CurrentContext.DefaultSecurity.GetUser(1234);<br />
Membership m = new Membership(user, club,<br />
"Reason why I want to join");<br />
// Add the membership to database<br />
m = ClubHandler.AddMembership(m);<br />
2.12.4 Adding Club Ads<br />
Club ads are used to promote a club in a community, either with images or text. In this article we explain how to create<br />
a new Club Ad with an ImageGallery Image attached to it.<br />
Import Necessary Namespaces<br />
First import the necessary namespaces that will be used to add a Club Ad. The namespaces<br />
StarCommunity.Modules.Club, StarCommunity.Core.Modules.Security and StarCommunity.Core are described by<br />
clicking on their respective names. Make sure you add the assemblies as a reference, mentioned in section 1.1.1.<br />
using StarCommunity.Core;<br />
using StarCommunity.Core.Mmodules.Security;<br />
using StarCommunity.Modules.Club;<br />
© <strong>EPiServer</strong> AB