@ -7,64 +7,106 @@ using System.Xml.Linq;
namespace FLocal.Common.dataobjects {
namespace FLocal.Common.dataobjects {
public class Board : SqlObject < Board > {
public class Board : SqlObject < Board > {
private class TableSpec : FLocal . Core . DB . ITableSpec {
public class TableSpec : FLocal . Core . DB . ITableSpec {
public const string TABLE = "Boards" ;
public const string FIELD_ID = "Id" ;
public const string FIELD_SORTORDER = "SortOrder" ;
public const string FIELD_CATEGORYID = "CategoryId" ;
public const string FIELD_LASTPOSTID = "LastPostId" ;
public const string FIELD_TOTALPOSTS = "TotalPosts" ;
public const string FIELD_TOTALTHREADS = "TotalThreads" ;
public const string FIELD_NAME = "Name" ;
public const string FIELD_DESCRIPTION = "Comment" ;
public static readonly TableSpec instance = new TableSpec ( ) ;
public static readonly TableSpec instance = new TableSpec ( ) ;
public string name { get { return "Boards" ; } }
public string name { get { return TABLE ; } }
public string idName { get { return "Id" ; } }
public string idName { get { return FIELD_ID ; } }
}
}
protected override FLocal . Core . DB . ITableSpec table { get { return TableSpec . instance ; } }
protected override FLocal . Core . DB . ITableSpec table { get { return TableSpec . instance ; } }
private string _ name ;
private int _ sortOrder ;
public string name {
public int sortOrder {
get {
get {
this . LoadIfNotLoaded ( ) ;
this . LoadIfNotLoaded ( ) ;
return this . _ name ;
return this . _ sortOrder ;
}
}
}
}
private string _d escription ;
private int _ categoryId ;
public string description {
public int categoryId {
get {
get {
this . LoadIfNotLoaded ( ) ;
this . LoadIfNotLoaded ( ) ;
return this . _d escription ;
return this . _ categoryId ;
}
}
public Category category {
get {
return Category . LoadById ( this . categoryId ) ;
}
}
}
}
private int? _l astPostId ;
private int? _l astPostId ;
public int lastPostId {
public int? lastPostId {
get {
get {
this . LoadIfNotLoaded ( ) ;
this . LoadIfNotLoaded ( ) ;
return this . _l astPostId . Value ;
return this . _l astPostId ;
}
}
}
}
private int _ categoryId ;
private int _ totalPosts ;
public int categoryId {
public int totalPosts {
get {
get {
this . LoadIfNotLoaded ( ) ;
this . LoadIfNotLoaded ( ) ;
return this . _ categoryId ;
return this . _ totalPosts ;
}
}
}
}
public Category category {
private int _ totalThreads ;
public int totalThreads {
get {
get {
return Category . LoadById ( this . categoryId ) ;
this . LoadIfNotLoaded ( ) ;
return this . _ totalThreads ;
}
}
private string _ name ;
public string name {
get {
this . LoadIfNotLoaded ( ) ;
return this . _ name ;
}
}
private string _d escription ;
public string description {
get {
this . LoadIfNotLoaded ( ) ;
return this . _d escription ;
}
}
}
}
protected override void doFromHash ( Dictionary < string , string > data ) {
protected override void doFromHash ( Dictionary < string , string > data ) {
this . _ name = data [ "Name" ] ;
this . _ sortOrder = int . Parse ( data [ TableSpec . FIELD_SORTORDER ] ) ;
this . _d escription = data [ "Comment" ] ;
this . _ categoryId = int . Parse ( data [ TableSpec . FIELD_CATEGORYID ] ) ;
if ( data [ "LastPostId" ] ! = "" ) {
if ( data [ TableSpec . FIELD_LASTPOSTID ] ! = "" ) {
this . _l astPostId = int . Parse ( data [ "LastPostId" ] ) ;
this . _l astPostId = int . Parse ( data [ TableSpec . FIELD_LASTPOSTID ] ) ;
} else {
} else {
this . _l astPostId = null ;
this . _l astPostId = null ;
}
}
this . _ categoryId = int . Parse ( data [ "CategoryId" ] ) ;
this . _ totalPosts = int . Parse ( data [ TableSpec . FIELD_TOTALPOSTS ] ) ;
this . _ totalThreads = int . Parse ( data [ TableSpec . FIELD_TOTALTHREADS ] ) ;
this . _ name = data [ TableSpec . FIELD_NAME ] ;
this . _d escription = data [ TableSpec . FIELD_DESCRIPTION ] ;
}
}
public XElement exportToXml ( ) {
public XElement exportToXmlForMainPage ( ) {
return new XElement ( "board" ,
return new XElement ( "board" ,
new XElement ( "id" , this . id ) ,
new XElement ( "sortOrder" , this . sortOrder ) ,
new XElement ( "categoryId" , this . categoryId ) ,
new XElement ( "lastPostId" , this . lastPostId ) ,
new XElement ( "totalPosts" , this . totalPosts ) ,
new XElement ( "totalThreads" , this . totalThreads ) ,
new XElement ( "name" , this . name ) ,
new XElement ( "name" , this . name ) ,
new XElement ( "description" , this . description )
new XElement ( "description" , this . description )
) ;
) ;