Esempio n. 1
0
        public static Articles GetArticleFromDb(NpgsqlConnection connection, int id)
        {
            var reader   = connection.GetDataFromDb($@"SELECT * FROM ARTICLES WHERE id = '{id}'");
            var articles = new Articles();

            if (reader.Read())
            {
                articles = ArticlesDAO.MadeNewArticleObject(reader);
            }
            reader.Close();
            return(articles);
        }
Esempio n. 2
0
        public static List <Articles> GetAllArticles(NpgsqlConnection connection)
        {
            var reader   = connection.GetDataFromDb($@"SELECT * FROM ARTICLES ORDER BY DATE_CREATE DESC");
            var articles = new List <Articles>();

            while (reader.Read())
            {
                articles.Add(ArticlesDAO.MadeNewArticleObject(reader));
            }
            reader.Close();
            return(articles);
        }