Ejemplo n.º 1
0
 public News GetNewsById(int newsId)
 {
     var news = new News();
     if (newsId > 0)
     {
         news = _newsRepository.GetNewsById(newsId);
     }
     else
     {
         //TODO:Haber yoktur
     }
     return news;
 }
Ejemplo n.º 2
0
        public News GetNewsById(int newsId)
        {
            var dataRowNews = sqlHelper.GetDataRow("select * from News where Id=" + newsId);
            var news = new News
                           {
                               Id = Convert.ToInt32(dataRowNews["Id"].ToString()),
                               Tittle = dataRowNews["Title"].ToString(),
                               Description = dataRowNews["Description"].ToString(),
                               ImageUrl = dataRowNews["ImageUrl"].ToString(),
                               Author = dataRowNews["Author"].ToString(),
                               Date = dataRowNews["NewsDate"].ToString()
                           };

            return news;
        }
Ejemplo n.º 3
0
        public NewsCollection GetNewsForHomePage(byte maxNewsCount)
        {
            var newsCollection = new NewsCollection();
            var dt = sqlHelper.GetDataTable("select top(" + maxNewsCount + ") * from News order by NewsDate  desc ");

            if (dt.Rows.Count > 0)
            {
                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    var news = new News
                    {
                        Id = Convert.ToInt32(dt.Rows[i]["Id"].ToString()),
                        Tittle = dt.Rows[i]["Title"].ToString(),
                        Description = dt.Rows[i]["Description"].ToString(),
                        ImageUrl = dt.Rows[i]["ImageUrl"].ToString(),
                        Author = dt.Rows[i]["Author"].ToString(),
                        Date = dt.Rows[i]["NewsDate"].ToString()
                    };
                    newsCollection.Add(news);
                }
            }
            return newsCollection;
        }