public PostDTO GetById(int id) { try { string sql = "SELECT ID, Title, PostContent, PostTime, AccountID, ForumID FROM Post WHERE ID = @ID"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("ID", id.ToString()), }; DataSet results = ExecuteSql(sql, parameters); PostDTO dto = DataSetParser.DataSetToPost(results, 0); return(dto); } catch (Exception e) { throw e; } }
public List <PostDTO> GetAll() { List <PostDTO> posts = new List <PostDTO>(); try { string sql = "SELECT ID, Title, PostContent, PostTime, AccountID, ForumID FROM Post"; DataSet results = ExecuteSql(sql, new List <KeyValuePair <string, string> >()); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { PostDTO dto = DataSetParser.DataSetToPost(results, x); posts.Add(dto); } return(posts); } catch (Exception e) { throw e; } }