private PodcastArticle ConvertToPodcastArticle(NewsArticle newsArticle)
 {
     return (PodcastArticle)newsArticle;
 }
 public void UpdateArticle(NewsArticle article)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 3
0
 public ViewArticle()
 {
     Article = new NewsArticle();
       ImageRelativeDirPath = string.Empty;
       PodcastRelativeDirPath = string.Empty;
 }
        private List<NewsArticle> SelectArticles(bool podcastsOnly)
        {
            List<NewsArticle> result = new List<NewsArticle>();

              MsSql db = new MsSql(_connectionString);

              //Call the appropriate stored procedure, based on whether or not we want news and podcasts,
              //or just podcasts only
              string storedProcedureName;
              if (podcastsOnly)
            storedProcedureName = "GetPodcasts";
              else
            storedProcedureName = "GetArticles";

              SqlCommand command = db.GetNewCommand(storedProcedureName, CommandType.StoredProcedure);

              try
              {
            db.AddErrorHandlingParamsToSqlCommand(command);

            SqlDataReader reader = command.ExecuteReader();
            try
            {
              int ordArticleId = reader.GetOrdinal("Id");
              int ordPostDateTime = reader.GetOrdinal("PostDateTime");
              int ordBodyText = reader.GetOrdinal("BodyText");
              int ordDownloadDisplayText = reader.GetOrdinal("DownloadDisplayText");
              int ordDownloadUrl = reader.GetOrdinal("DownloadUrl");

              while (reader.Read())
              {
            //Check to see if we have podcast information for the current record
            NewsArticle newArticle;
            if ((reader[ordDownloadDisplayText] == DBNull.Value) || (reader[ordDownloadUrl] == DBNull.Value))
            {
              //We are missing podcast download info, so we have a news article
              newArticle = new NewsArticle();
            }
            else
            {
              //We have download info, so we have a podcast article
              newArticle = new PodcastArticle()
              {
                //Grab the URL download info while we're here
                PodcastUrl = new DynamicUrl()
                {
                  Url = reader.GetString(ordDownloadUrl),
                  DisplayText = reader.GetString(ordDownloadDisplayText)
                }
              };
            }

            newArticle.Id = reader.GetInt64(ordArticleId);
            newArticle.PostDateTime = reader.GetDateTime(ordPostDateTime);
            newArticle.BodyText = reader.GetString(ordBodyText);

            if (newArticle is PodcastArticle)
            {
              //We need to retrieve album information for the podcast
              LoadPodcastAlbums((PodcastArticle)newArticle);
            }

            //Add the new article to the result
            result.Add(newArticle);
              }
            }
            finally
            {
              reader.Close();
            }

            db.FreeCommand(command);
              }
              catch (Exception ex)
              {
            db.FreeCommand(command, false);
            throw ex;
              }

              return result;
        }
Ejemplo n.º 5
0
 public ViewArticles()
 {
     Articles = new NewsArticle[0];
       ImageRelativePath = string.Empty;
       PodcastRelativePath = string.Empty;
 }