Patterns and Origins: Sueetie Member Following

Sueetie Member Following is complete for BlogEngine.NET post authors and commenters.  While implementation of member following for, say, YetAnotherForum.NET will be somewhat different than member following for BlogEngine.NET, I like to write up the documentation while the code is still fresh, so here is the newest Sueetie Wiki document, “The Design of Sueetie Member Following.”  I’ll update the wiki after I implement following on YAF.NET, ScrewTurn Wiki and Gallery Server Pro.

I hope to have the source code on CodePlex in a couple of weeks.  I want to finish Following and Favorites on BlogEngine.NET and YetAnotherForum.NET, then upgrade BE.NET to 1.5.

The document starts in the database backend, then moves back up to the page covering the Sueetie WCF Service, the JQuery script, and finally the code that creates the HTML on the BlogEngine.NET page.  For more information about Sueetie Friends and Favorites, see my earlier announcement.


Sueetie supports Following Members by adding buttons and links to members associated with application content like blog post authors, commenters, forum threads originators, reply authors, media object contributors, and more. This document will grow as the support for Member Following evolves. See Sueetie Favorites for information on the related functions of tagging content as Favorites.

An Overview of Sueetie Member Following

Below is an example of a Sueetie button to follow the author of a BlogEngine.NET post. The button is generated with JQuery and uses Ajax to call a WCF Service performing the data processing. The Follow logic is akin to the Twitter model of following rather than Facebook friends, as no official request for friendship is performed. Friend status is attained when reciprocal following occurs.

Example of a Sueetie Following Button

Sueetie Member Following: Patterns

Each application requires a slightly different approach to supporting Sueetie Member Following. We will cover implementation of following at the application level after looking at the shared logic and data structure of Member Following.

Data Logic

Two Sueetie SQL tables are used to hold Following data, Sueetie_Followers and Sueetie_UserFriendsFavorites. The pertinent fields in UserFriendsFavorites are highlighted.

Member Following Tables

One important point to make here is that the data logic supporting Following and Favorites was designed with site analytic capabilities in mind. We’ll get more into that with Sueetie Favorites, but one eye-to-analytics item shown here is the ContentIDFollowed field in Sueetie_Followers. This ID is keyed to the content item viewed when the act of following occurs, possibly yielding valuable insights into what prompted the act of following an individual by other community members.

When populated, the tables appear as below.

Following Table Data

WCF Service Logic

Each of the applications’ client-side JQuery scripts call /app_code/SueetieService.cs to populate the tables and calculate the updated totals in followers, following and friends. (The calculations are performed in SQL Stored Procedures, Sueetie_Follower_Add and Sueetie_Follower_Remove.)

The logic of the WCF method is to retrieve an enhanced blog post object containing Sueetie User and Content data to populate the SueetieFollow data object. SueetieFollow is then passed to the data provider in SueetieUsers.FollowUser(sueetieFollow);

You’ll notice that the user must be authenticated to follow a member (as Following buttons and links are displayed universally regardless of user status), and a user cannot following himself.

public string BlogAuthorFollow(int userID, string postGuid) { SueetieBlogPost sueetieBlogPost = SueetieBlogs.GetSueetieBlogPost(postGuid); if (userID > 0) { if (sueetieBlogPost.SueetiePostID > 0) { string result = "You are now following " + sueetieBlogPost.DisplayName; SueetieFollow sueetieFollow = new SueetieFollow { FollowerUserID = userID, FollowingUserID = sueetieBlogPost.SueetieUserID, ContentIDFollowed = sueetieBlogPost.SueetiePostID }; if (sueetieFollow.FollowerUserID == sueetieFollow.FollowingUserID) result = "Sorry, you cannot follow yourself..."; else SueetieUsers.FollowUser(sueetieFollow); return result; } } else return "Please login or become a member to follow this person."; }

The JQuery Script

Because each application yields author and content identification data differently, the JQuery is typically unique to that content, like BlogEngine.NET blog posts and comments. The script below in /scripts/sueetie.js is used to call the WCF BlogAuthorFollow() method shown above. The ASPNET AJAX ScriptManager control is used to perform the communications.

function followPostAuthor(postGuid, blnMember, followDiv) {
    SueetieService.BlogAuthorFollow(postGuid, blnMember, 
        onFollowFaveSuccess, null, followDiv);

function onFollowFaveSuccess(result, followDiv) {
  $(followDiv).slideUp("fast", function() {
  $(followDiv).click(function() {
    return false;


We’re at the page level now where we create the HTML to execute the JQuery to call the WCF Service. In BlogEngine.NET we’re going to create a custom Sueetie.Blog Class Library to add our Sueetie Follow and Favorite services.

We’ll isolate our code from BlogEngine.NET’s source code base by creating a custom Sueetie.Blog class library project from which we will reference BlogEngine.Core.  Then we’ll add our custom comment and post base classes.

Sueetie.Blog Class Library Project

Here is the code used to enable the followPostAuthor() script.

C# HTML Code

Sueetie Member Following: Origins

Member Following was one of the first Sueetie “add-ons.”  It was important to support a Following and Friends function because communities are all about the people in them, and strong communities are all about the depth of communication between its members. Spending a lot of time in Twitter (and very little in Facebook), the Following concept seemed more natural than a strict “Friends” approach.

As for the technical origins of Member Following, we looked at BlogEngine.NET comments source and YetAnotherForum.NET functions like “Watch this thread.” Both of these functions were fast and client-side requiring no postback, which was the top priority for Following and Favorites. This was an excellent opportunity to start using JQuery in Sueetie, so this was the technology we chose. Plan to see a lot of JQuery, AJAX and WCF in future Sueetie features.

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.