Exemple #1
0
        public int DeleteNews(int id)
        {
            int i = 0;

            using (SqlCommand command = new SqlCommand())
            {
                i = ExecuteNonQuery(NewsStringsSql.DeleteNews(id));
            }

            return(i);
        }
Exemple #2
0
        public List <News> GetAllNews()
        {
            DataTable   dt      = new DataTable();
            List <News> arrNews = new List <News>();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(NewsStringsSql.GetAllNews());
            }

            foreach (DataRow ms in dt.Rows)
            {
                arrNews.Add(News.ToObject(ms));
            }
            return(arrNews);
        }
Exemple #3
0
        public News UpdateNews(News value)
        {
            DataTable dt   = new DataTable();
            News      news = new News();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(NewsStringsSql.UpdateNews(value));
            }

            foreach (DataRow ms in dt.Rows)
            {
                news = News.ToObject(ms);
            }
            return(GetNewsById(value.newsID));
        }
Exemple #4
0
        public News GetNewsById(int id)
        {
            DataTable dt = new DataTable();

            if (id < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            News news = new News();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(NewsStringsSql.GetNewsById(id));
            }

            foreach (DataRow ms in dt.Rows)
            {
                news = News.ToObject(ms);
            }
            return(news);
        }