Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
As a newbie I'm creating MemberGroups programatically but want to check if it already exists before I create it - which routine do I use please?
You can do that using the Services API:
var umbracoContext = UmbracoContext.Current; var services = umbracoContext.Application.Services; var groupExists = services.MemberGroupService.GetAll().Any(x => x.Name == "MyGroupName");
Excellent - Thank you!
Apologies - should have mentioned I'm using V7 and getting an error on the code:
services.MemberGroupService.GetAll().Any(x => x.Name == "MyGroupName");
Error is: IEnumerable<IMemberGroup> does not contain a definition for 'Any'
Error is: IEnumerable<IMemberGroup> does not contain a definition for 'Any
Make sure to have a reference to System.Linq:
using System.Linq;
Doh!
Thank you!!!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to find if MemberGroup Exists
As a newbie I'm creating MemberGroups programatically but want to check if it already exists before I create it - which routine do I use please?
You can do that using the Services API:
Excellent - Thank you!
Apologies - should have mentioned I'm using V7 and getting an error on the code:
Error is: IEnumerable<IMemberGroup> does not contain a definition for 'Any
'Make sure to have a reference to System.Linq:
using System.Linq;
Doh!
Thank you!!!
is working on a reply...