Пример #1
0
 public ReplyDTO GetById(int id)
 {
     try
     {
         string sql = "SELECT ID, ReplyContent, Pinned, ReactionTime, PostID, AccountID, Username FROM Reply 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);
         ReplyDTO dto     = DataSetParser.DataSetToReply(results, 0);
         return(dto);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #2
0
        public List <ReplyDTO> GetAll()
        {
            List <ReplyDTO> replies = new List <ReplyDTO>();

            try
            {
                string  sql     = "SELECT ID, ReplyContent, Pinned, ReactionTime, PostID, AccountID, Username FROM Reply";
                DataSet results = ExecuteSql(sql, new List <KeyValuePair <string, string> >());

                for (int x = 0; x < results.Tables[0].Rows.Count; x++)
                {
                    ReplyDTO dto = DataSetParser.DataSetToReply(results, x);
                    replies.Add(dto);
                }
                return(replies);
            }
            catch (Exception e)
            {
                throw e;
            }
        }