I am looking for the most appropiate way of dealing with a user activity feed on my social networking site. At the moment i have several activities which can appear on the news feed such as:
- Users joins the site
- User comments on a post
- User adds a a post to their favourites
- User adds a new post to the site
Here is a simplified version of my domain objects at the moment:
public abstract class NewsItem : Entity, ITenantSpecific
{
public virtual Account Account { get; set; }
public virtual DateTime DateTime { get; set; }
// returns formatted news html string which gets
// overridden by inherted classes
public abstract string GetNewsHtml();
}
public class NewsItemJoiner : NewsItem
{
public virtual Account AccountJoined { get; set; }
public override string GetNewsHtml()
{
return "XXX has just joined our music network";
}
}
As you can see at the moment I have a property which must be overridden on each activity called GetNewsHtml
. This isn't ideal as I don't believe my domain should be responsible for generating my html.
I have thought about using a partial view for each activity type and pass into it the NewsItem
base class downcasted into the correct type.
However I am open to suggestions.