Work with groups
Create groups
To create a group:
- Get an instance of the
Comment Serviceby using theGetCommentsServicemethod part of theSystemManager. - Create an
AuthorProxy.
When creating comments information is required about the author of the new comment, for example a name, an email, and so on. Therefore, there is anAuthorProxyclass that implements theIAuthorinterface. - To create a group, you need to create a
GroupProxy. The constructor requires as parameters a title, description, and an author. - Create the group using the
CreateGroupmethod as part of the comment service by passing thegroupProxyas a parameter.
The following code creates a group:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Security.Claims;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
using Telerik.Sitefinity.Services.Comments.Proxies;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Comments.Groups
{
public partial class CommentsSnippets
{
public IGroup CreateGroupSnippet(string title, string description)
{
var cs = SystemManager.GetCommentsService();
var author = new AuthorProxy(ClaimsManager.GetCurrentUserId().ToString());
var groupProxy = new GroupProxy(title, description, author);
var group = cs.CreateGroup(groupProxy);
return group;
}
}
}
Query groups
Choose any of the following options to retrieve groups:
-
Get a thread by
groupKey:C#using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Telerik.Sitefinity.Services; using Telerik.Sitefinity.Services.Comments; namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Comments.Groups { public partial class GetGroup { public IGroup GetGroupSnippet(string groupKey) { var cs = SystemManager.GetCommentsService(); return cs.GetGroup(groupKey); } } } -
Get all groups by specific criteria.
You must use theGetGroupsmethod part of the comments service:C#using System.Collections.Generic; using Telerik.Sitefinity.Services; using Telerik.Sitefinity.Services.Comments; namespace SitefinityWebApp { public class GetGroup2 { public IEnumerable<IGroup> GetGroupSnippet2(GroupFilter filter) { var cs = SystemManager.GetCommentsService().GetGroups(filter); return cs; } } }or
C#using System.Collections.Generic; using Telerik.Sitefinity.Services; using Telerik.Sitefinity.Services.Comments; namespace SitefinityWebApp { public class GetGroup3 { public IEnumerable<IGroup> GetGroupSnippet3(GroupFilter filter) { int totalCount = 0; ICommentService cs = SystemManager.GetCommentsService(); IEnumerable<IGroup> gr = cs.GetGroups(filter, out totalCount); return gr; } } }
Delete groups
You can delete group using the DeleteGroup. ```C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Telerik.Sitefinity.Services;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Comments.Groups { public partial class CommentsSnippets { public void DeleteGroup(string groupKey) { var cs = SystemManager.GetCommentsService(); cs.DeleteGroup(groupKey); } } }
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.