Book Image

ASP.NET 3.5 Social Networking

By : Andrew Siemer
Book Image

ASP.NET 3.5 Social Networking

By: Andrew Siemer

Overview of this book

Table of Contents (19 chapters)

Solution


Now let's take a look at the solution.

Implementing the database

First let's take a look at what tables are needed:

Moderations

The moderation table shown in the following screenshot holds the SystemObjectID and SystemObjectRecordID as well as the Account that created the content in question. It also carries the Account that executed the resulting action as well as what that action is.

In addition to tables, we are going to need a way to quickly and easily determine if a bit of content has been flagged or not. I hate to say it boys and girls, but we are going to dip into the actual SQL for this one. We will create a function that will take a SystemObjectID and a SystemObjectRecordID and determine if that item is flagged or not.

create function [dbo].[IsFlagged]
(
	@SystemObjectID int,
	@SystemObjectRecordID bigint
)
returns bit 

as
begin
	declare @result bit
	if exists (
		select 1 
		from moderations 
		where systemobjectid = @SystemObjectID and 
			systemobjectrecordid = @SystemObjectRecordID...