public int DeleteNews(int id) { int i = 0; using (SqlCommand command = new SqlCommand()) { i = ExecuteNonQuery(NewsStringsSql.DeleteNews(id)); } return(i); }
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); }
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)); }
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); }